How can you access the contents of Android Emulator databases?

I’ve read the answer to a question as to how to access the contents of the databases, however I cannot seem to get it to work on my machine. Here is the shell log:

C:\android-sdk-windows\tools>adb -s emulator-5554 shell
# sqlite3 /data/data/com.android.demo.notepad2/databases/notes
sqlite3 /data/data/com.android.demo.notepad2/databases/notes
SQLite version 3.5.9
Enter ".help" for instructions
sqlite> .tables
.tables
sqlite> ^C
C:\android-sdk-windows\tools>

SQLite simply echos my commands back to me, even although the Eclipse file browser tells me it exists. If I use the sqlite3 tool and use “.tables” the commands are accepted.

Is the SQLite syntax different through the emulator is am I missing something?

(Sorry for so many questions, there doesn’t seem to be much coherent documentation on Android!)

Thanks!

I can tell you that it works fine for me on Android 2.0.1:

$ adb shell
# cd /data/data/apt.tutorial   
# ls
lib
databases
shared_prefs
# cd databases
# ls
lunchlist.db
# sqlite3 lunchlist.db
SQLite version 3.5.9
Enter ".help" for instructions
sqlite> .tables
android_metadata  restaurants     
sqlite> .exit
# exit

You can always download the database file using DDMS or adb pull and use a desktop SQLite client to examine it. For example, I use the SQLite Manager plugin for Firefox.

Also, bear in mind that SQLite has no default file extension, so if your database is not notes but notes.db or notes.sqlite or something, you’ll need to specify the extension.

Also also, I have not tried this on Windows, and there’s a possibility that there is something goofy with the Windows command prompt and the limited shell available on Android devices that is causing your difficulty.

Leave a Comment