Extract database of an application from android de

2020-07-23 03:45发布

问题:

How to extract database of an application from android device through adb shell command?

Thanks

回答1:

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


回答2:

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.



回答3:

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.



回答4:

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