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?
- Root phone.
- Copy the database data file to the mobile phone sdcard: cp (db) (sdcard).
- 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
Context.Startforegroundservice() Did Not Then Call Service.Startforeground()
Error:(1, 0) Plugin With Id 'Com.Android.Application' Not Found
How to Detect When an Android Application Is Running in the Emulator
Android Studio Add External Project to Build.Gradle
Receiving Package Install and Uninstall Events
How to Sign an Android APK File
Android Fragment Onclick Button Method
How to Create a Custom Navigation Drawer in Android
Store and Retrieve a Class Object in Shared Preference
Android: How to Display Video Thumbnails
Android Pick Images from Gallery
How to Disable Mobile Data on Android
Need to Handle Uncaught Exception and Send Log File
Using Facebook Sdk in Android Studio
How to Have Onscrolllistener for a Scrollview