I am developing an app and I know my database *.db will appear in data/data/com.****.***
I can access this file from AVD in Eclipse with help of sqlite manager
But I can't access this file in my Android phone.
I googled it and it says I need to root my phone to do it, but I don't want to do that.
How can I access my data/data/..... directory in my Android phone "without rooting it"?
Can I change user permissions for the directory data/data..... without rooting it?
18 Answers
Accessing the files directly on your phone is difficult, but you may be able to copy them to your computer where you can do anything you want with it. Without rooting you have 2 options:
If the application is debuggable you can use the
run-ascommand in adb shelladb shell run-as com.your.packagename cp /data/data/Alternatively you can use Android's backup function.
adb backup -noapk com.your.packagenameYou will now be prompted to 'unlock your device and confirm the backup operation'. It's best NOT to provide a password, otherwise it becomes more difficult to read the data. Just click on 'backup my data'. The resulting 'backup.ab' file on your computer contains all application data in android backup format. Basically it's a compressed tar file. This page explains how you can use OpenSSL's zlib command to uncompress it. You can use the
adb restore backup.dbcommand to restore the backup.
If you are using Android Studio 3.0 or later version then follow these steps.
- Click View > Tool Windows > Device File Explorer.
- Expand /data/data/[package-name] nodes.
You can only expand packages which runs in debug mode on non-rooted device.
You could also try fetching the db using root explorer app. And if that does not work then you can try this:
- Open cmd
- Change your directory and go into 'Platform tools'
- Type '
adb shell' su- Press 'Allow' on device
chmod 777 /data /data/data /data/data/com.application.package /data/data/- Open DDMS view in Eclipse and from there open 'FileExplorer' to get your desired file
After this you should be able to browse the files on the rooted device.
To do any of the above (i.e. access protected folders from within your phone itself), you still need root. (That includes changing mount-permissions on the /data folder and accessing it)
Without root, accessing the /data directly to read except from within your application via code isn't possible. So you could try copying that file to sdcard or somewhere accessible, and then, you should be able to access it normally.
Rooting won't void your warranty if you have a developer device. I'm sorry, there isn't any other way AFAIK.
The easiest way (just one simple step) to pull a file from your debuggable application folder (let's say /data/data/) on an unrooted Android 5.0+ device is by using this command:
adb exec-out run-as package.name cat databases/file > file
- Open your command prompt
- Change directory to E:\Android\adt-bundle-windows-x86_64-20140702\adt-bundle-windows-x86_64-20140702\sdk\platform-tools
- Enter below commands
adb -d shellrun-as com.your.packagename cat databases/database.db > /sdcard/database.db- Change directory to
cd /sdcardto make suredatabase.dbis there. adb pull /sdcard/database.dbor simply you can copy database.db from device .
Use File Explorer in eclipse. Select Windows => Show View => Other ... => File Explorer.
An another way is pull the file via adb:
adb pull /system/data/data/<yourpackagename>/databases/<databasename> /sdcard
To backup from Android to Desktop
Open command line cmd and run this: adb backup -f C:\Intel\xxx.ab -noapk your.app.package. Do not enter password and click on Backup my data. Make sure not to save on drive C root. You may be denied. This is why I saved on C:\Intel.