On a non-rooted android device, I can navigate to the data folder containing the database using the run-as
command with my package name. Most files types I am content with just viewing, but with the database I would like to pull if from the android device.
Is there a download
copy
or move
command from this part of adb shell? I would like to download the database file and view its content using a database browser.
One answer here involves turning entire application package into a compressed archive, but there is no further answer on how to extract that archive once this is done and moved to the machine, leaving me very sidetracked when there might be a more direct solution to begin with
I couldn't get anything else to work for me but this:
The first exit is to exit out of the run-as, the second exit is to exit out of adb shell to do the pull.
The accepted answer doesn't work anymore for me (blocked by Android?)
So instead I did this:
For app's debug version, it's very convenient to use command
adb exec-out run-as xxx.yyy.zzz cat somefile > somefile
to extract a single file. But you have to do multiple times for multiple files. Here is a simple script I use to extract the directory.Hope it would be helpful. This script is also available at gist.
Typical usage is
then it will extract all files under your apps databases directory, which is
/data/data/com.example.myapplication/databases
, into current directory.If someone is looking for another answer that can be used to retrieve
Database
as well asShared Preferences
then follow this step:In your
build.gradle
file of your app add linenow when you run your app in
non-release
mode then your app will automatically open 8080 port from your deviceIP address
make sure your device is connected viawifi
and yourlaptop
is sharing the same network. Now simply visit the urlto watch all data of database along with shared preferences.
You can use this script for get Realm database.
Here's a solution that works on a device running Android 5.1. The following example is for Windows.
You need sed ([https://www.gnu.org/software/sed/manual/sed.html] or sed.exe on windows, e.g. from cygwin.) ( On Unix, it'll just be there ;) ). To remove bad '\r' characters, at least on windows.
Now just run the following command:
The sed command strips out trailing /r characters.
Of course you should replace "com.yourcompany.yourapp" with the package name of the app and "YourDatabaseName" with the name of the database in the app.