There is an application on Android . I'm trying to write some text to a file. The file name I get is:

String filename = getFilesDir() + File.separator + "myfile.txt"; 

I end up with the following value for the file name:

/data/data/com.nm.myapp/files/myfile.txt

Data is normally written to the file. However, I cannot find this file on my phone when I try to open it with some kind of text file viewer. I just do not have such a folder on the device: /data/data .

I tried to find the file using different file managers, but could not do it. At the same time, the file definitely exists - I can write lines to it, the exists method returns true , and I can also read the contents of it programmatically. But when I just need to view this file, it’s not very convenient to read it programmatically each time and look in the debugger.

Can you please tell how you can find and see this elusive file?

    3 answers 3

    You need either root on your smartphone or use an emulator, it will have access.

      All right, Android protects your application data from prying eyes. Look here https://stackoverflow.com/questions/13006315/how-to-access-data-data-folder-in-android-device can find a solution.

        If you want to view the contents, then create a file in the folder to which you have access. For example:

         File testDirectory = new File(Environment.getExternalStorageDirectory() + "/Android"+"myFile.txt");