I am currently working on a WiFi application for Android. I’m having trouble accessing the device’s database. Debugging in the emulator does not work for me because the emulator does not support WiFi. I tried to extract the file from the device’s database using
retrieve adb data/data/package/database name
But I got the error message Permission denied.
In this answer, Android: Where the database files are stored, Commonsware suggested removing the file from the database by executing the debug mode. But that doesn’t work either. Any help with troubleshooting the database without routing the device is greatly appreciated.
How can I solve this problem?
I’ll repeat myself with a different answer:
From API level 8 (Android 2.2) onwards, when creating an application as a debugger, you can use the Run-as-shell to execute a command or executable on behalf of a specific user/application, or simply browse your application’s UID to access the data folder.
So, if you want to retrieve the application database from the device, you need to run the debug compilation of the application, login via the adb shell and execute the following command:
run-as com.yourpackage sh -c cat ~/databases/db-file > /sdcard/db-file.sqlite
This will copy your db file to the root directory of the SD card/external storage. Now you can just take it with you with a case manager, a salesman or whatever. Note that with this approach, your application does not need to have WRITE_EXTERNAL_STORAGE authorization, as the copy is made by the shell user, who can still write data to the external memory.
On Linux/Mac systems it is possible to copy the database directly to the computer without entering the adb-shell with the following command:
adb shell ‘run-as com.yourpackage sh -c cat ~/databases/db-file’ > db-file.sqlite
However, this does not work well under Windows because of the CR/LF character conversion. In this case, use the old method.
I use this shell script on my MAC that copies the database directly to my personal folder. Simple one-click solution, just change the name of the package (com.example.app) and the name of the database (database.sqlite).
shell adb -d ‘run-as com.example.app cat /data/data/com.example.app/databases/database.sqlite > /sdcard/database.sqlite’
adb pull /sdcard/database.sqlite ~/
A script that accepts [packet name] [database] arguments.
If [ $# -ne $REQUIRED_ARGS ]
echo android_db_move.sh [packet name] [db_name] echo z. B. android_db_move.sh lt.appcamp.impulse.db
cmd1=$ADB_PATH -d shell ‘run-as $1 cat /data/$1/databases/$2’
cmd2=$ADB_PATH pull /sdcard/$2 $PULL_DIR
if [ $ ? -eq 0 ] then
if [ $ ? -eq 0 ]
The best way to view and manage the database of your Android application is to use this library https://github.com/sanathp/DatabaseManager_For_Android.
This library allows you to manage your application’s SQLite database from within the application itself.
you can view, update, delete tables in the database of your application, insert rows in the tables, all in your application.
This is a single activity java file, paste the java file into the source directory. When development is complete, delete the Java file from your src folder that contains it.
It helped me a lot. I hope you do, too.
You can watch a one-minute demonstration here: http://youtu.be/P5vpaGoBlBY.
Although I think it’s an old question, it’s still relevant and deserves an answer as it is now. There are tools that make it possible to examine databases directly (without having to remove them from the device or emulator).
The tool I recently discovered (and which I prefer) is the Android debugging database.
Add this dependency:
No additional code is required.
After starting the application, open the logcat and filter for DebugDB and you will see a message that reads.
D/DebugDB : Open http://192.168.178.XXX:8080 in your browser
It works with any browser and you can view the database tables and general settings.
It also works with standard and Genymotion emulators.
The tool I’ve used so far is a stetho.
Disadvantage: You need to add code and you are linked to the Chrome browser.
Advantage: You also have the ability to monitor network traffic.
Solution No 5:
In my application I export the database to an SD card. Once the database is on the SD card, it can be accessed by connecting the device to a computer.
Look at this message: Backing up the SDCard database on Android.
Solution No 6:
The system cannot find the specified path.
adb -d shell run-as com.yourpackage cat /data/data/com.yourpackage/databases/dbname.sqlite > /sdcard/dbname.sqlite
Pay attention to the quotation marks!
Solution No 7:
The new Android Studio 4.1 offers a new database inspector.
You can select the following options from the menu bar View > Windows Tool > Database Inspector to open it (App Inspector in Android Studio 4.2). For more detailed instructions, see this blog and the article Exploring the Database Inspector in Android Studio.
Another option is the use of a stethos. If you add a dependency, you can use Chrome DevTools ( chrome://inspect ) to check the database when you connect the device.
Solution No 8:
I just did:
[protected via e-mail]:/$ run-as myapp.package.name sh
[protected via e-mail]:/data/data/myapp.package.name $
Then I can debug the sqlite database or whatever I want to do with the proper rights.
Solution No 9:
There is a way, when apk debugs, to use a program called run axis of the adb (non-root) shell to copy the private file of the application.
Solution No 10:
Here are step-by-step instructions, most of which are derived from a combination of other answers. This works with devices that are not unlocked.
- Connect the device and run the application in debug mode.
- Copy the database file from the application folder to the SD card: Execute:
./adb -d shell ‘run-as com.ihrpackge.name cat /data/com.ihrpackge.name/databases/filename.sqlite > /sdcard/filename.sqlite’.
- Drag and drop files from the database to your computer: Execute:
./adb pull /sdcard/ execute: ./adb
- Install the SQLLite manager of Firefox: https://addons.mozilla.org/en-US/firefox/addon/sqlite-manager/.
- Open Firefox SQLLite Manager and open the database file from step 3.
- Have fun!
how to breed donkeys in minecraft,minecraft horse propagation,how to make golden carrots,how to make golden apples,how to breed horses in real life,how to breed skeleton horses in minecraft,how to breed horses and donkeys,how to get golden apples in minecraft,how to make golden carrots in minecraft,minecraft horse stats mod,minecraft best horse command,horse speed tester minecraft,ender horse,give best horse minecraft,minecraft horse stable,how to feed a horse in minecraft ps4,how to breed llamas in minecraft,how to breed horses bdo,how to feed animals in minecraft pe,how to tame a sheep in minecraft,what do cows eat in minecraft,how to tame a chicken in minecraft,how to breed chickens in minecraft,minecraft breed all the animals advancement,how to make horses grow faster,how to make golden carrot in minecraft,how to breed villagers in minecraft 2020,minecraft horse breeding chart,minecraft horse breeding guide,how to breed horses in minecraft 2020,minecraft horse breeding chart vanilla,how to feed a horse in minecraft,how to get a fast horse in minecraft,how to breed horses and donkeys in minecraft,minecraft horse breeding colors