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

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.tar
adb exec-out run-as debuggable.app.package.name tar c shared_prefs/ > shared_prefs.tar

Android Adb, retrieve database using run-as but with file name that has space

You should use the quotation mark "

chmod 666 databases/"my db"

Is there any way to reach the SQLite database file which I made inside of an Xamarin.Forms application?

  1. Root phone.
  2. Copy the database data file to the mobile phone sdcard: cp (db) (sdcard).
  3. Open a terminal in the folder of the computer and use: adb pull (sdcard/db) to copy to the computer.

ZODB: using both regular FileStorage as well as Zlib compressed storage

zstorage = ZODB.FileStorage.FileStorage('testz.fs') # testz.fs has been created with ZlibStorage
try:
db = ZODB.DB(zstorage)
except:
zstorage.close()
zstorage = zc.zlibstorage.ZlibStorage(ZODB.FileStorage.FileStorage('testz.fs'))
db = ZODB.DB(zstorage)

Not as robust as it should be (improve it with the correct Exception which is _pickle.UnpicklingError)

Can't pull database file from Android phone on 5.1

This question has been successfully answered by Alex P here - android adb, retrieve database using run-as

Here's a quick look at the answer:

the command for Android 5.0+ to save
/data/data/package.name/databases/file would be:

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

I need help on a query regarding fetching data from a database file

The answer was to add group by Pin on the end.

select * from Temperature where Pin in (21,20,16,12) and Module =1 group by Pin

I am so stupid

How to pull a file through ADB?

You are trying to access the private folder file which is not accessible in non-rooted android device. For that you need to get the adb shell access then provide the permission to access that directory.

For this use case, I have created a library that can help you. It's open-sourced.

https://medium.com/@mohom.r/extracting-android-data-files-of-our-android-app-from-non-rooted-device-be9084ddbdc3



Related Topics



Leave a reply



Submit