Copy a (db) file from an installed Android apk
I've been looking at doing some performance tuning on a troublesome sql query on a sqlite db on an Android app and wanted tocopy the actual db to do some testing in an IDE.
It took a long time reading various SO articles to find something that worked, but eventually found this (answer from Triplee).
Basically you need to run adb shell, run-as
the package to impersonate the permissions, then use cat
to pipe the file to another location on the device (sdcard which is available on the emulator), then use adb pull
to copy to the host machine, so steps are:
- Open adb command prompt (you can do this through Visual Studio)
adb shell
run-as com.package.name
cat foldername/dbfilename.db > /sdcard/dbfilename.db
exit
exit
- adb pull /sdcard/dbfilename.db "c:\users\youruser\desktop\dbfilename.db"
Works nicely!