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/
sqlite3 /data/data/
SQLite version 3.5.9
Enter ".help" for instructions
sqlite> .tables
sqlite> ^C

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!)


Asked by: Brianna275 | Posted: 20-01-2022

Answer 1

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

$ adb shell
# cd /data/data/apt.tutorial   
# ls
# cd databases
# ls
# 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.

Answered by: Adelaide937 | Posted: 21-02-2022

Answer 2

If you want to issue sqlite3 statements from command line use something like

$ adb -e shell sqlite3 -batch /data/data/com.example.dbsample/databases/db '.tables'

$ adb -e shell sqlite3 -batch /data/data/com.example.dbsample/databases/db 'select * from android_metadata;'

the obvious advantages are that you can rely on your shell history and you can use this in scripts.

Answered by: Byron942 | Posted: 21-02-2022

Answer 3

I had the same problem and discovered that contrary to the documentation you shouldn't put the ".db" extension on the database file name.

Note: I'm using win7 and 2.1 emulator.

Answered by: Freddie572 | Posted: 21-02-2022

Answer 4

I had the same issue ,spent almost an hour ,posting here so that it will save someone else time ,check if you have given the correct filename along with the extension, there are two files under the databases folder myDB.db and myDB.db-journal and when i ran
"sqlite3 /data/data/"
listed nothing, sqlite3 created a new db with the name myDB , it did not open myDB.db

Answered by: Adrian397 | Posted: 21-02-2022

Similar questions

about databases in android

i am new in android database.i downloaded sqlite database browser. can u give me the steps how to use already generated database in android sdk with eclips. give me proper structure where to store database in eclips folder structure

android - pulling "Create" strings from SQLite3 databases

Is there a simple way to get the CREATE string from each of your tables in Android instead of redefining them in onCreate override. I am annoyed enough to just parse the whole thing for each table, but I am hoping there is an easier way I have not found yet.

New to Android. Is it possible for the user to specify the name of a Database to be created? Also on using multiple databases

I'm very new to Android. I'm thinking about creating an application that uses multiple databases. The user would be able to specify the name of the database to be created, and select which database to use from those existing in the /databases/ directory. Is this possible in android?

storing data in databases in android

i am having a program in which i am having 4 edittext name,age,contact,email. I am having 2 buttons save and view.I want a program of how to save values. I will be very thankful to you.

Help - android databases

I have an application which downloads contacts periodically (using a service and asyn task), but at the same time I read the contacts which were already downloaded. My problem is, when I'm downloading the contacts, I try to read the database, the application crashes. Could someone explain to me how I can read and write to the database simultaneously. Any help would be much appreciated.

How can I pull databases off my android onto my desktop?

I'm trying this with my Nexus One. I have the android SDK and have used the command adb pull /data/data/ C:\pulls but all I get is pull: building file list... 0 files pulled. 0 files skipped. Also, it seems no matter how much data I add to the tutorial NotePad app I installed, the data size for the app (as shown in Settings) never exceeds 8KB. How is this possible? Is there some other place w...

android - Why are sqlite databases located on sdcard readonly when using min-sdk tag in manifest?

I have posted this question over a week ago on the Android dev list but so far no responses. I have run into a weird issue. I work with a database located on /sdcard/ and for some reason whenever I add <uses-sdk android:minSdkVersion="8" /> to the manifest sqlite opens the db as read only. It gets a bit weirder too. The below code opens the db and checks if the db is readonly, which returns false...

Android SQLite databases

I want to have a SQLite database for my android application. Anyone knows how to create a database and add information not going through an application class. Is there some user interfaces allow create a SQLite database, add tables, information and later use in the application. thanks.

sql - Android multiple databases open

I am making a IM client for android and I am working with databases for storing the contacts and other info's... In my app I have an activity and one service. I need to open three databases in the same time both on the service and on the activity. I use three database because I want the databases to be managed more easily without having problems with the synchronization of writing in them. (as far as I know I need ...

Backing up databases in android cloud:

Can I use the Android Cloud to back up my application's databases? What are some limits to this feature?

Still can't find your answer? Check out these communities...

Android Google Support | Android Community | Android Community (Facebook) | Android