Can't pull database file from Android phone on 5.1 [duplicate] - android

This question already has answers here:
Retrieve database or any other file from the Internal Storage using run-as
(12 answers)
Closed 7 years ago.
I have a non-rooted Nexus 5 on Android 5.1.
I've tried multiple solutions described here Android ADB access to application databases without root in order to pull a debugable app database from the file system, but to no avail. Has anybody managed to make it work on 5.1 ?
When trying to copy to sdcard, I get cp: /sdcard: Permission denied
When trying to pull the file directly, I get remote object '/data/data/packagename/databases/name.db' does not exist

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

Related

How to pull a file through ADB? [duplicate]

This question already has answers here:
Retrieve database or any other file from the Internal Storage using run-as
(12 answers)
Closed 3 years ago.
Actually in my application after an intent is sent I create a file called myfile.asc now i'm trying through ADB to pull that file but the issue is that by using
adb pull /data/data/xx.xxx.xxx/files/myfile.asc
or
adb pull /data/data/xx.xxx.xxx/files/myfile.asc C:\Users\me\Desktop\files
it returns
"remote object does not exist"
The path is actually taken from the Android Studio device File Explorer by clicking on the file and copying the path.
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

How fast extract db file from Android device? [duplicate]

This question already has answers here:
Retrieve database or any other file from the Internal Storage using run-as
(12 answers)
Closed 4 years ago.
In my Android project I use Realm.
Sometimes I need to extract db file from device.
To do this I follow the next steps:
Open console
adb shell
run-as my_project_name_space
cd files
cp my_db_file.realm /sdcard
exit
exit
adb pull sdcard/my_db_file.realm d:\Temp\my_db_file.realm
As result in folder d:\Temp I get db file: my_db_file.realm
Nice. It's work fine.
But when I need again to extract db file I must again do all of this 8 steps.
Has any faster approach?
Something like start script that execute all of this 8 steps. Or or something similar.
Thanks.
In debug apk you can use android studio's device explorer
goto path
/data/data/your-package-name/files/your-db.realm
and by right clicking you can save it without running any kind of code.

Adb pull database from android device [duplicate]

This question already has answers here:
Android - Pulling SQlite database android device
(19 answers)
Closed 7 years ago.
I know how to pull db from android device through adb but i have got few samsung device like S4 adb is not working. when I run
run-as packagename
It says package does not exist and it works in other devices.
Any idea why it is happening like that??
You can also get the db file from Eclipse/studio
Open DDMS ==> File explorer tab
Move to /data/data/your packagename/databases
Select the required .db file and press pull button. (You will find it on top right corner of file explored) and save the file at required location
(OR)
Go to command prompt
c:> adb pull /data/data/your packagename/databases/dbfilename.db savefilelocation(ex: /username/Desktop/x.db)

How to extract sqlite database from android device using ADB? [duplicate]

This question already has answers here:
Retrieve database or any other file from the Internal Storage using run-as
(12 answers)
Closed 4 years ago.
I followed the step by step instructions given in the answer of How do I view the SQLite database on an Android device?
1) Connect your device and launch the application in debug mode.
2) Copy the database file from your application folder to your sd
card. You may want to use adb -d shell "run-as com.resmed.mon ls
/data/data/com.resmed.mon/databases/" to see what the database
filename is.
3) adb -d shell "run-as com.yourpackge.name cat
/data/data/com.yourpackge.name/databases/filename.sqlite >
/sdcard/filename.sqlite"
(in my case "/data/data/com.mypackge.name/databases/MyDb")
4) Pull the database files to your machine:
5) adb pull /sdcard/filename.sqlite .
6) Install Firefox SQLLite Manager:
https://addons.mozilla.org/en-US/firefox/addon/sqlite-manager/
7) Open Firefox SQLLite Manager (Tools->SQLite Manager) and open your
database file from step 3 above."
But in my case, the database extracted is always empty. When i open the file on SQL Lite Manager, i can't find my tables and my data. I don't understand why. I can see the data on my device screen using my app in debug mode. Is there an other folder where my database could be stored ?
My phone is not rooted.
Thanks for your help.
PS : I wanted to comment on the previous answer, but my reputation is too low to interact with the answer.
I've published a simple shell script for dumping databases:
https://github.com/Pixplicity/dbdump
It performs two distinct methods described here:
First, it tries to make the file accessible for other users, and attempting to pull it from the device.
If that fails, it streams the contents of the file over the terminal to the local machine. It performs an additional trick to remove \r characters that some devices output to the shell.
From here you can use a variety of CLI or GUI SQLite applications, such as sqlite3 or sqlitebrowser, to browse the contents of the database.
As far as I remember, you shouldn't be able to extract a database from un-rooted device. You can however get it from an emulator!

Root Access on Android SDK (Emulator) [duplicate]

This question already has answers here:
How to get root access on Android emulator?
(15 answers)
Closed 7 years ago.
I have installed SQLite Editor app on the emulator but its showing that ;The application don’t have root permission. Tried apps like SuperUser to provide root access bur unable to do the same.
What is the best way to gain root access from Emulator itself? Please post the step by step process to gain the root access on Android SDK.
Use the shell, that already gives you root access on the emulator:
(on your computer)
$ adb -e shell
$ cd /data/data/org.myapp/databases
$ sqlite3 mydb.db
AFAIK, you can't give give an app super user access on the emulator by installing the Superuser.apk.

Categories

Resources