15

I need get SQLite database from Android app from Genesis device where user has populated by hand.

How I can create another app or any other way to get this db and save in place where I can get?

obs.: the device has root

Thanks

6 Answers 6

14

Steps from .../platform-tools of Android on cmd:

1) type adb shell

2) run-as com.your.package

3) type ls

cache

databases

lib

You can find Your Database Here...Also You didn't even have to root the Device

Hope this could helpful for you...

Sign up to request clarification or add additional context in comments.

5 Comments

Hi nitesh, Thanks by the answer. When I run the command I receive this message "(app path)/databases/database.db: cannot execute - Permission denied"
Have created the db..are you the super user if your using linux...rember the cmd is (run-as your package path)
@PauloKussler Run your project into emulator ..you will find the databse into file explorer /data/data/databases
Hi @nitesh and all!, The db was created by GreenDao. And the biggest problem is the device is not here and can be I need make this by remote support. Can be the problem is biggest that than. I tested on other device and has received the same message of Permission denied. I will make more tests and post here after. Thanks!!!
This solution can be shortened into a one-liner: adb shell run-as <package> cat databases/<dbFilename> >> <outfile>
6

Provided you have the device attached to a box with adb on the PATH you can use this command:

adb -d shell 'run-as your.package.name.here cat /data/data/your.package.name.here/databases/your_db_name_here.sqlite > /sdcard/recovered_db.sqlite'

Or you can use Ecliplse DDMS file explorer.

1 Comment

Note that /sdcard may need to be altered depending upon the device to the proper spot for referencing external storage.
4

VERY EASY WAY TO DO IT

In the latest releases of Android Studio (I am using AS v3.1.2) the Google team has made it really straight forward. You just have to open the Device File Explorer window which should be at the bottom of the right vertical toolbar, if you cannot find it you can also open it this way:

View -> Tool Windows -> Device File Explorer

Once you have Device File Explorer window open, use your mouse to navigate to the following path:

data -> data -> your.package.name -> databases

Inside the databases folder you should see the database you want to explore, do a right click and Save As... select your desired computer destination folder and voila!!

1 Comment

For real devices in Android Studio Bumblebee 2021.1.1 patch 3 the Device File Explorer only shows the directories you can see in the file manager of your device, so no databases directory.
3

You can either include the Stetho library on your app,

http://facebook.github.io/stetho/

which will allow you to access your DB using Chrome's Web Debug tools

or use the following shell script:

#!/bin/bash
echo "Requesting data from Android"
adb backup -f data.ab -noapk YOUR.APK.NAME
echo "Decoding...."
dd if=data.ab skip=24 iflag=skip_bytes | python -c "import zlib,sys;sys.stdout.write(zlib.decompress(sys.stdin.read()))" | tar -xvf -
rm data.ab
echo "Done"

```

None of the methods above require your device to be rooted and the latter works even on apps that you did not write yourself, as long as the ApplicationManifest.xml does not contain "backup=false"

Comments

1

After trying dozens of commands that didn't work for me on Marshmallow, I've found this one that works (for debuggable apps at least):

adb shell "run-as your.package.name cp /data/data/your.package.name/databases/you-db-name  /sdcard/file_to_write"

Then you simply can view the DB with aSQLiteManager for instance.

Comments

1

You can use this script.

humpty.sh

You should know the application package name and sqlite database name. You can check the available databases.

$ adb shell
$ run-as <package-name> 
$ ls databases/

To dump database or other file.

./humpty.sh -d <package-name> databases/<db-name>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.