Retrieve database or any other file from the Internal Storage using run-as Retrieve database or any other file from the Internal Storage using run-as database database

Retrieve database or any other file from the Internal Storage using run-as


By design user build of Android (that's what you have on your phone until you unlock the bootloader and flash the phone with userdebug or eng software) restricts access to the Internal Storage - every app can only access its own files. Fortunately for software developers not willing to root their phones Google provides a way to access the Internal Storage of debuggable versions of their packages using run-as command.

To download the /data/data/debuggable.app.package.name/databases/file from an Android 5.1+ device run the following command:

adb exec-out run-as debuggable.app.package.name cat databases/file > file

To download multiple files in a folder under the /data/data/debuggable.app.package.name/ at once - use tar:

adb exec-out run-as debuggable.app.package.name tar c databases/ > databases.taradb exec-out run-as debuggable.app.package.name tar c shared_prefs/ > shared_prefs.tar


The accepted answer doesn't work anymore for me (blocked by Android?)

So instead I did this:

> adb shellshell $ run-as com.example.packageshell $ chmod 666 databases/fileshell $ exit                                               ## exit out of 'run-as'shell $ cp /data/data/package.name/databases/file /sdcard/shell $ run-as com.example.packageshell $ chmod 600 databases/file> adb pull /sdcard/file .


If anyone looking for pulling database from debug application may use the procedure below:

  1. search and open device file explorer

search and open device file explorer

  1. Select your handset and then browse to data/data directory

go to data/data directory

  1. Now find your application package and go to databases folder. You can see the databases there and upon right click, you will get option to save this in your drive.

enter image description here