5

How can I extract the database of an application from an android device through an adb shell command?

TarHalda
  • 1,050
  • 1
  • 9
  • 27
Siddharth_Vyas
  • 9,972
  • 10
  • 39
  • 69

5 Answers5

8

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.

Aliaksei
  • 101
  • 1
  • 3
4

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
S.D.
  • 29,290
  • 3
  • 79
  • 130
0

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:

  1. run-as com.packagename
  2. cp /data/data/com.packagename/databases/databaseName.db databaseNameNewFile.db
  3. 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.

TarHalda
  • 1,050
  • 1
  • 9
  • 27
-1

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.

Antrromet
  • 15,294
  • 10
  • 60
  • 75
-1

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

Richa
  • 3,165
  • 1
  • 22
  • 26