A. Riesbeck
A. Riesbeck

Reputation: 59

Android Studio, unable to access data folder for database file on emulator

Ok, I have searched and searched without any success for someone with a similar question. I am developing an Android app using Android Studio and have started creating my SQLite database. In order to test my creation and upgrade functions I would like to extract my SQLite database and view it's contents.

Instructions online are fairly clear, open up Android Device Monitor, select the device, go to file explorer, and then browse a few levels deep in the data folder to find your .db file. Here is where the trouble starts. I am unable to expand the root level data folder at all. I have found numerous other questions regarding people having the same problem but they are all due to people trying to do it on un-rooted physical devices. I am simply trying to do it on an emulated device. I am certain it is a permissions problem but I'm not sure how to fix it.

Things I've tried:

  1. Verified that my app is listed as a process on the device selected in the device monitor.
  2. Restarted the AVD, Android Studio, and then my entire machine.
  3. Uninstalled my app and reinstalled.

TLDR; can't access data folder in DDMS for emulated device in order to extract SQLite database file.

Upvotes: 2

Views: 5351

Answers (2)

rosuh
rosuh

Reputation: 483

Same question to me. When I want to access /data directory via Android Device Monitor, some error have occurred :

08-21 07:32:36.837: W/ls(3101): type=1400 audit(0.0:50): avc: denied { getattr } for path="/default.prop" dev="rootfs" ino=2941 scontext=u:r:shell:s0 tcontext=u:object_r:rootfs:s0 tclass=file permissive=0 08-21 07:32:37.418: W/PlatformStatsUtil(2507): Could not retrieve Usage & Diagnostics setting. Giving up.

This information tells us we don't have permission to access the directory. Here are what I have done and works for me.

My OS is Window10

  • Start your ADV & Open Android Device Monitor

  • cd to /the/path/to/Android/sdk/platform-tools

  • Open your cmd or openshell here (shift + right click you will see the option)
  • execute following commands

.

./adb.exe shell
su
chmod -R 777 /data/data/your/package

Now, enjoy your coding.

Upvotes: 1

Minyoung Jung
Minyoung Jung

Reputation: 11

Run your app in an emulator with API 23 (or lower).

check detailed information in link below,

Android Device Monitor "data" folder is empty

Upvotes: 0

Related Questions