I would like to extract my Android database so I can examine it, but I cannot figure out how. I am aware of the two common methods (e.g., adb pull and copying to the SD card). I have successfully used the "copying to the SD card" method before, but neither one of those methods is working for me now.
I say "now" because I switched to a pre-populated database with this version of my application using this method.
When I use adb shell
and cd
to /data/data/com.myapp/databases/
, this is what I see when I run ls -l
:
drwxrwx--x u0_a106 u0_a106 2017-07-19 11:03 cache
drwxrwx--x u0_a106 u0_a106 2017-07-19 11:03 databases
lrwxrwxrwx install install 2017-07-19 11:03 lib -> /data/app-lib/com.myapp
drwxrwx--x u0_a106 u0_a106 2017-07-19 11:03 shared_prefs
Notice that even though I am in the proper "databases" sub-directory, there is still another "databases" directory underneath that.
Now, when I execute this command:
run-as com.myapp ls -l databases
I see this:
-rw-rw---- u0_a106 u0_a106 21504 2017-07-19 15:53 MYDB
-rw------- u0_a106 u0_a106 8720 2017-07-19 15:53 MYDB-journal
There is my database, in that (one level deeper) "databases" directory. I have tried using the adb pull
command, but Android tells me /data/data/com.myapplicaiton/databases/MYDB does not exist
.
So, I tried the next level, and still I get /data/data/com.myapplicaiton/databases/databases/MYDB does not exist
.
Then I tried using the "copying to the SD card" method. I get a database, but it is 0 bytes in size.
Weird, because I can obviously see the database exists and it has a size larger than 0 bytes.
So ... what is going on, and how can I get my database?
Thanks.
EDIT:
Per a request, I'm adding the code I use to extract the database:
adb shell run-as com.myapplication cat /data/data/com.myapplication/databases/MYDB > /mnt/ext_sdcard/MYDB.db
I also tried:
adb shell run-as com.myapplication cat /data/data/com.myapplication/databases/databases/MYDB > /mnt/ext_sdcard/MYDB.db
Then I use adb pull /mnt/ext_sdcard/MYDB.db
to retrieve it from the tablet.