I want to save a .txt file to my external storage with this code:
String exportTitle = etTitle.getText().toString();
String exportContent = etContent.getText().toString();
noteExporter.run(exportTitle, exportContent);
And this:
public void run(String title, String content){
if(isExternalStorageWritable()) {
try {
File file = new File(Environment.getExternalStorageDirectory() + "/" + title + ".txt");
Boolean append = file.createNewFile();
FileOutputStream fos = new FileOutputStream(file, append);
OutputStreamWriter writer = new OutputStreamWriter(fos);
writer.append(content);
writer.close();
fos.close();
} catch (Exception e) {
e.printStackTrace();
Log.e("ERROR", e.toString());
}
}
}
The File is saved on the external storage, but I can only see it on my phone after restarting my phone. I'm using Android Studio and use my phone as testing device. Questions has been ask before here, but not answered.