androidfile-permissionsdata-storageandroid-device-monitor

Get access to data directory for private data storage


I develop an Android application and I would store some JSON data on the phone in private mode. I'll check if the file is created in the data/data/<package-name>/shared_prefs directory, but I don't get the correct permissions.

I use Android Device Monitor to check it. Here you've a screenshot of the monitor. When I click on the data directory, it doesn't open.

Screenshot of monitor (Click on image for full screen)

How could I give the data directory and the files the correct permissions to access it and read or write file to it?

Here you've more information about my application


Solution

  • You cannot get access to this directory from "outside" (only if it's a rooted device). From your app you have permission to access to this folder by default (both read and write). Just call the getFilesDir() to access to the folder. http://developer.android.com/reference/android/content/ContextWrapper.html#getFilesDir()