11

I'm trying to access the sqlite database file on the device. I mean, I've launched the app on the device via adb. And now I wanto to download this file as I did before on emulator via DDMS. But when I select the device on DDMS and open the folder data, it is empty.

Is it the right way to do? Or there is another way to download this db file.

Thanks.

1

2 Answers 2

36

You can access to the data folder without root, provided the application is debuggable

<application
 ...
        android:debuggable="true"
 ...

To list the base directory :

adb shell "run-as com.your.package ls -l"

To copy a file :

adb shell "run-as com.your.package cat relative/path > /sdcard/some_name"
adb pull /sdcard/some_name

Unfortunately pre-ICS run-as is quite buggy. The usual symptom is a

run-as: Package 'com.your.package' is unknown

message.

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

6 Comments

Then just use something like sourceforge.net/projects/sqlitebrowser to read the file. sudo aptitude install sqlitebrowser
There is no need to set android:debuggable="true" in manifest as you compile a project from debug certificate it will automatically set to true.
When running this on an emulator I got the error: /system/bin/sh: can't create /sdcard/habits.db: Read-only file system In order to write I needed to remount the filesystem: stackoverflow.com/questions/2083709/…
What should I do when the resulting file is empty?
@AndrewOrobator I've got better solution: stackoverflow.com/a/29257875/291427
|
3

Have you tried adb directly?

adb pull /data/data/the.package.of.the.app/databases/the_name_of_the_database.db

6 Comments

This probably won't work on non-rooted devices
yeah. but the data folder is empty. I click and the hierarchy three doesnt open. just shows the data folder, I dont know why. =/
@Damp you are right... it's still hard for me to think of a android developer with a non-rooted phone.
@rogcg the /data/ directory is not empty. It just doesn't show anything in it because you are probably using a non-rooted phone. This is a protection mechanism because it keeps developers from snooping around at other people's apps on our phones. Unfortunately it also keeps you from looking at your own apps data...
It will work on non-rooted devices as long as you have access to the file, which can be granted from the app itself. See: stackoverflow.com/a/24705519/1002098
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.