0

I have written a method for an Android application:

public void doMethod()throws IOException{
    Log.d("STORAGE", Environment.getExternalStorageDirectory().toString());
    File file = new File(context.getExternalFilesDir("NOTES")+"TEST.txt");
    Log.d("FILE", file.createNewFile()+"");

    FileOutputStream os = new FileOutputStream(file);
    BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(os));
    bw.write("HELLO WORLD");
    bw.close();
    Log.d("WRITE", "DONE");
}

In spite of executing this code (calling this method from an activity), I cannot see the file TEST.txt in my phone's file manager when I open the NOTES directory.

The directory named NOTES is being created without a problem. Where is my TEST.txt file going to?

bruno
  • 2,213
  • 1
  • 19
  • 31
Debanik Dawn
  • 797
  • 5
  • 28
  • 1
    https://stackoverflow.com/questions/32789157/how-to-write-files-to-external-public-storage-in-android-so-that-they-are-visibl – CommonsWare Apr 12 '18 at 16:16
  • 1
    `I cannot see the file TEST.txt in my phone's file managaer `. You should use a file explorer app on your device to check if files are created. Further it looks as if you created a file NOTESTEST.txt instead of TEST.txt. – greenapps Apr 12 '18 at 17:52

0 Answers0