App-specific files on Android are deleted at startup

29 views Asked by At

I create a file at the onCreate callback following the Android guide

File folderSamples = new File(getApplicationContext().getFilesDir().getAbsolutePath());
    File test = new File(folderSamples, "text.txt");

    try {
        FileWriter fw = new FileWriter(test);
        fw.write("hello there");
        fw.close();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }

The file is created correctly and I can open it on the device manager. My problem is that when I reboot the application on Android Studio the file is deleted, I don't see it on the device manager and the application can't find it...what do I do wrong? Are those file meant to be deleted everytime the application is started? Thank you for your replies.

0

There are 0 answers