我正嘗試在我的HTC Hero手機中將文件寫入我的SD卡。我使用以下命令在SDCard中創建文件:在SDCard上寫入問題 - Android
File = new File(path.getAbsolutePath(),「Filename.txt」);
其中path是我externalStorageDirectory(即\ SD卡)
當我登錄這個文件的路徑,但它說\ SD卡\ FILENAME.TXT
但是,當我創建一個FileOutputStream要寫入文件,突然將文件路徑更改爲\ data \ data,我無法訪問它。
有人可以請幫助澄清如何我可以在SDCard中創建一個文件,然後寫入它?
謝謝!
編輯:
path = Environment.getExternalStorageDirectory();
Log.d("SDCARDPLSWORK", path.toString());
try
{
myFile = new File(path.getAbsolutePath(), "SensorValues.txt");
boolean i = myFile.createNewFile();
Log.d("SDCARDPLSWORK", myFile.toString() + " " + i);
fos = new FileOutputStream(myFile);
Log.d("FILEANDROID", getFileStreamPath("SensorValues.txt").toString());
}
catch(FileNotFoundException e)
{
e.printStackTrace();
}
這是我在做什麼。直到SDCARDPLSWORK是正確的部分,但是當涉及到FILEANDROID日誌時,它會轉到專用數據存儲。
路徑= Environment.getExternalStorageDirectory(); Log.d(「SDCARDPLSWORK」,path.toString()); 嘗試 { \t myFile = new File(path.getAbsolutePath(),「SensorValues.txt」); \t布爾型i = myFile.createNewFile(); \t Log.d(「SDCARDPLSWORK」,myFile.toString()+「」+ i); \t fos = new FileOutputStream(myFile); \t Log.d(「FILEANDROID」,myFile。getAbsolutePath()); (FileNotFoundException e) } catch(FileNotFoundException e) { \t e.printStackTrace(); – Imelza 2010-12-01 08:18:48
對不起,我在做什麼,我認爲,但它不工作。 – Imelza 2010-12-01 08:22:34