Search code examples
androidandroid-storage

Accessing Android app's internal files dir


I'm creating an app that should, as an intermediate step, output some data to a file in the app's internal file dir. How can I test that the file's contents are created properly, given that adb won't let me copy this file onto the developer's machine?

adb pull /data/user/0/com.example.myapp/files/output.png

adb: error: failed to stat remote object '/data/user/0/com.example.myapp/files/output.png': Permission denied

I can run the adb shell under the app's linux user, but then I can only perform the checks that are available via the command-line, so I cannot e.g. see the picture with my own eyes.

I can write the same file to the external storage that is accessible, but aside from it requires additional code to get the write-external-storage permission, it doesn't test the same thing.

I can also root the phone, but I feel that to access my file on my app-under-development on my phone, it's pretty ridiculous to require such a drastic step as rooting.


Solution

  • You can test it on an emulator using the Device File Explorer in Android Studio. But for a physical device you'll need to root it.