How can I extract the database of an application from an android device through an adb shell command?
-
Asked 1000 times on here – smk Feb 07 '13 at 05:52
5 Answers
If you have neither SD card nor root on your device, just use adb shell.
$ adb shell
$ run-as com.your.package cat /data/data/com.your.package/databases/your_db > /storage/sdcard0/Download/your.db
Then use DDMS to pull file out.

- 101
- 1
- 3
-
2I am certain this will only work if your package has debuggable set to true. – beenhere4hours Apr 25 '14 at 22:34
-
Just note that the last path may be different for you. Its /sdcard/Download/your.db on my Nexus 5 – urSus Sep 19 '16 at 11:41
Databases are stored in files, mostly on internal storage, in App's data directory like :
/data/data/com.example.myapp/mydb
so you can do
adb pull /data/data/com.example.myapp/mydb
Then you can use some software to open that file, and work with data base. To place it back:
adb push <new file> /data/data/com.example.myapp/mydb

- 29,290
- 3
- 79
- 130
As of Android 9, the Download
directory has moved to /storage/emulated/0/Download/
. I combined this answer and this answer with the new location to pull the database file:
run-as com.packagename
cp /data/data/com.packagename/databases/databaseName.db databaseNameNewFile.db
cp databaseNameNewFile.db /storage/emulated/0/Download
Then I enabled file transfer on the phone, opened it with File Explorer, went to Internal Storage/Download, found the database file, and copied it to my computer.

- 1,050
- 1
- 9
- 27
AFAIK you can fetch databases only from Android Emulator, not from real device (unless the device is rooted).
To do so, simply go to DDMS --> File Explorer --> data --> data --> your package name -- > databases
Your database should be inside databases folder
Once you select your database, you will see two icons on the upper tab wherein you can push or pull the database.

- 15,294
- 10
- 60
- 75
I dont think u can extract extract database from device, but yes you can extract it from emulator from DDMS > File Explorer > data > data > package > databases

- 3,165
- 1
- 22
- 26