Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android ADB access to application databases without root

Tags:

android

adb

root

Can anyone tell me, is it possible to use the ADB to pull and push a database from an app, without root privileges on the phone?

For example, I know the location on my rooted magic and dream is:

/data/data/com.xxxx.xxxx/databases/xxxx 

I know that you can use ADB without root, but when trying to use the shell - you can't view that location without root privaliges. But I have been told you can use push and pull if you know the file you want?

Basically I want to pull a database from MY app on a non rooted phone modify it and push it back on.

Only trouble I have is, the two phones I have are both root and I don't have access to a non root one to try it out.

like image 693
Scoobler Avatar asked Jan 16 '10 19:01

Scoobler


People also ask

Does ADB work without root?

You don't need to be rooted to use ADB, all android phones can use ADB without being rooted. You must be rooted to push applications to /system/apps/ to make them system applications.

How do I browse files with ADB?

Open cmd type adb shell then press enter. Type ls to view files list. At the DOS prompt, adb shell ls -R > junk lists all files and puts results into file junk which you can then edit via Notepad or whatever and see more than you'd want to, but your files, too!

What is ADB exec out?

Resolution. Use the ADB option exec-out instead of shell in the screencap command. For example, adb exec-out screencap screenshot. png. This command will store the screenshot direct on your PC in the folder where you have started the command.


1 Answers

While Nilhcem's answer didn't work for me, it lead me in the right direction (for that I upvoted) and I now have a working solution.

Old answer that may not work with newer versions of Android:

#Transfer file from app databases directory to PC adb shell $ run-as package.name $ cd ./databases/ $ ls -l #Find the current permissions - r=4, w=2, x=1 $ chmod 666 ./dbname.db $ exit $ exit adb pull /data/data/package.name/databases/dbname.db ~/Desktop/  #Transfer file from PC to app databases directory (requires the above permission change) adb push ~/Desktop/dbname.db /data/data/package.name/databases/dbname.db adb shell $ run-as package.name $ chmod 660 ./databases/dbname.db #Restore original permissions $ exit $ exit 

Alternate method using external storage (confirmed to work with 6.0.1):

#Transfer file from app databases directory to external storage adb shell $ run-as package.name $ cp ./databases/dbname.db /sdcard/ $ exit $ exit  #Transfer file from external storage to app databases directory adb shell $ run-as package.name $ cp /sdcard/dbname.db ./databases/ $ exit $ exit 
like image 153
Pilot_51 Avatar answered Oct 11 '22 03:10

Pilot_51