3

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.

Community
  • 1
  • 1
odgatelmand
  • 393
  • 1
  • 5
  • 16
  • @AlexP. - That doesn't seem to cover the case here, of obtaining a file but finding it empty. – Chris Stratton Apr 08 '15 at 19:38
  • Several thoughts: one is that recent Android builds are multiuser, and each user may have their own data directory, which the above method might not be finding. Another is that your app may not actually be committing its DB changed - if you swipe the app out of recents to kill it, and re-launch, are they there? Finally, your fetching operations (particularly the shell redirect) might conceivably be failing in some way that didn't generate error output, but did result in creation of an empty file. – Chris Stratton Apr 08 '15 at 19:40

2 Answers2

3

I've published a simple shell script for dumping databases:

https://github.com/Pixplicity/dbdump

It performs two distinct methods described here:

  1. First, it tries to make the file accessible for other users, and attempting to pull it from the device.
  2. 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.

Paul Lammertsma
  • 37,593
  • 16
  • 136
  • 187
-1

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!

Samuil Yanovski
  • 2,837
  • 17
  • 19
  • 1
    The purpose of the run-as tool in the quoted instructions is specifically that it allows performing this type of operation on a secured device, if and only if the apk is debuggable. However, poking around more extensively on an emulator wouldn't be a bad idea. – Chris Stratton Apr 08 '15 at 19:36