.txt 文件需要保存在 SD 卡中。
Save("n" + String.valueOf(key) + ".txt");
private void Save(String FileName){
File fileName = null;
String sdState = android.os.Environment.getExternalStorageState();
if (sdState.equals(android.os.Environment.MEDIA_MOUNTED)) {
File sdDir = android.os.Environment.getExternalStorageDirectory();
fileName = new File(sdDir, "FlyNote/"+FileName);
} else {
fileName = context.getCacheDir();
}
if (!fileName.exists())
fileName.mkdirs();
try {
FileWriter f = new FileWriter(fileName);
f.write(editText2.getText().toString());
f.flush();
f.close();
} catch (Exception e) {
}
}
但在 SD 卡中的文件另存为文件夹。文件夹“n5.txt”和其他...