我想要保存文件到我的SD卡。這是我迄今爲止的代碼。我非常感謝您提供的任何幫助。謝謝 編輯: 問題是該文件未保存。當我退出程序並查看SD卡時,沒有文件被保存。我向錯誤捕獲器中添加了一個敬酒,它看起來像我得到一個IOException。我不知道如何檢查堆棧跟蹤日誌雖然在android中保存文件到SD卡的問題
class bSaveListen implements Button.OnClickListener{
@Override
public void onClick(View arg0) {
savef();
}
}
public void savef(){
sdCard = Environment.getExternalStorageDirectory();
String filename = "aaaaaaa.txt";
file = new File(sdCard, filename);
FileOutputStream fileout;
byte[] thatString = new String("awesome string").getBytes();
try {
fileout = new FileOutputStream(file);
fileout.write(thatString);
fileout.flush();
fileout.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
那麼,有什麼問題呢? – neevek
那麼最新的問題?有什麼異常? – waqaslam
您是否在您的清單中提供了權限 –
Aerrow