我在Android中嘗試了一個簡單的文件寫入程序。在Android中使用SD卡寫入文件
try
{
//File f1=new File("/sdcard/Prag.txt");
File f1=new File("J:\\Prag.txt");
BufferedWriter out = new BufferedWriter(new FileWriter(f1,true));
out.write("Pragadheesh" + "\n");
out.close();
} catch (IOException ioe)
{ioe.printStackTrace();}
但是異常正在受到打擊。我怎樣才能解決這個問題?
[編輯]: 我試過File f1=new File(Environment.getExternalStorageDirectory() + "//Prag.txt");
和F1值= /mnt/sdcard/Prag.txt 但仍然是例外被擊中。我在清單文件
[解決方案] 變更許可也按Krishnabhadra的答覆,我必須確保你的SD卡沒有安裝在PC上
發佈錯誤日誌.. – user370305