Question

Hi I know that when we are using emulator for run an App in android we are able to get the database and shared preference file from File explorer. Like wise is there any method to obtain the database and shared preference from device when we are testing the App using usb debugging.

Any help will be appreciable

Was it helpful?

Solution

Assuming your device is not rooted.

In this case, you have to make sure the app you want to retrieve is debug signed (not a 3rd party commercial app).

Then there are 2 ways to get the db and other files:

Way 1: See the content inside adb shell

Run below command:

adb shell

run-as [your app package name] 

(above command will let you to go to /data/data/[your app package name] folder)

cd databases

sqlite3 [your database file name]

(this will start a sqlite3 prompt, you can do simple db browsing with it)

Way 2: Pull the file to local

Run below command:

adb shell run-as [your app package name] chmod 666 databases/[your databases file name]

adb pull /data/data/[your app package name]/databases/[your database file name]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top