Reputation: 93
I recently created an Emulator device with Android Studio,but only to find that I can't open the /data/data folder to get the sqlite db file.The folder just can't open,I have tried to use shell scirpt to chmod the /data directory,but it says the su command not found.
Is there anyone has the same problem? Or I have to root the Emulator? But it's an Emulator! I just think it's kind of inconvenient to root a Emulator!
Upvotes: 8
Views: 13391
Reputation: 2509
Update
Can't remember whether it's from Android Studio 3.0 or later but if you have downloaded AS 3.3+, you'll find the tab on bottom right corner called Device File Explorer
, which lets you to see and easily get the data of your app without rooting.
Opening as Administrator didn't help but rooting the phone did worked, and no I'm not lowering my SDK version.
Open cmd and go to C:\Users\{User}\AppData\Local\Android\Sdk\platform-tools or to the folder location and type cmd
at the address bar.
Whether you're super user or not can be determined by $
:
C:\{User}\...\platform-tools>adb shell
generic_x86:/ $ exit
To have su/root privileges type adb root
and exit:
C:\{User}\...\platform-tools>adb root
generic_x86:/ # exit
Next run the Android Device Monitor to extract the data.
To turn off root type adb unroot
.
Upvotes: 15
Reputation: 81
Using Android Studio 3.1.2 and DDMS is no longer available under the Tool options. Instead Android Studio has the "Device File Explorer" tab available on the bottom right (I know why put it there).
Click on the "Device File Explorer" tab and select the Android Device you want to explore. To actually access the files, make sure USB Debugging is turned on in the AVD.
If that doesn't work, you'll need to use Terminal panel.
C:\Users\B\AppData\Local\Android\sdk\platform-tools> adb pull /data/data/com.example.b.expensewatcher/databases/myexpenses.db
/data/data/com.example.b.expensewatcher/databases/myexpenses.db: 1 file pulled. 3.3 MB/s (24576 bytes in 0.007s)
For more details on changing folder permissions see: https://www.dev2qa.com/android-device-monitor-cannot-open-data-folder-resolve-method/
Upvotes: 1
Reputation: 1
Instead of rooting your android phone, you can access the data folder from android studio by opening 'device file explorer' which is to the bottom right corner of your IDE. Open 'data>data>packagename>databases' you can save the database files but this will be in the encrypted form. You can directly access it from the file explorer on your PC.
Install DB Browser for SQLite and select option 'open database.'
Connect your android device and enable 'File Transfer'. Go to the directory where your android studio has been installed i.e., in my case documents. Then,
C:\Users\prana\Documents\AndroidStudio\DeviceExplorer\xiaomi-redmi_note_4-164594b\data\data\com.android.packagename\databases
You can find your databases here.
Hope it helps!
Upvotes: 0
Reputation: 577
Even after running Android Studio as administrator if you can't access data/data folder, try using API 23 or lower for you emulator device.
Upvotes: 2
Reputation: 596
Use adb to root the emulator device. Once that is done, you will have permission to access the data\data folder
adb shell
su
The adb tool will be present in Users\\AppData\Local\Android\sdk1\platform-tools
Open cmd, change directory to above folder and enter the above code Restart Android device monitor (if needed)
Upvotes: -2
Reputation: 714
open DDMS with administrator previlledges. Had same issue and it solved it. Fastest means to doing this is opening android studio with administrator previledges and opening DDMS from there.
otherwise, have a look at this link Android device monitor
Upvotes: 0