5

In Android I can create an SQLite database from my app (I'm using Eclpise with Android SDK and the emulator, I made the SQL code in a separate designer and then just pasted it). After getting rid of a few initial errors, the SQLiteOpenHelper-descendant class initialization code ran without any exceptions, so I'm assuming the database has been created (and presumably persisted in a file).

How could access the database and examine it?

(I mean other than from the actual app, which at this point has no functionality to speak of.) I'd like to have a look at the database structure, and later when the app gradually becomes capable of adding data, I'd like to be able to chcek if it's working properly.

philipxy
  • 14,867
  • 6
  • 39
  • 83
Shaggydog
  • 3,456
  • 7
  • 33
  • 50

6 Answers6

5

Here is what I do (I'm running Windows 7):

  • A batch file that pulls the database file from the device / emulator to my local filesystem:

Here is the content of that batch file:

cd C:\Development\Android\android-sdk\platform-tools

adb pull /data/data/<your package name>/databases/<your database file name> <your local path> 
Guillaume
  • 22,694
  • 14
  • 56
  • 70
  • 1
    Note that after editing the database using SQLite Database Browser as above, you can push back to the device using the equivalent method: cd C:\Development\Android\android-sdk\platform-tools adb push \ /data/data//databases/ I simply save the two bat files as pull.bat and push.bat to retrieve and edit my database before returning it to the device. – Warren Sergent May 12 '13 at 20:42
3

You can access the SQLite Data through the DDMS included in Android SDK and integrated in Eclipse.

In this link they say how to do this.

Where does Android emulator store SQLite database?

Community
  • 1
  • 1
Neonamu
  • 736
  • 1
  • 7
  • 21
1

First you have a command-line tool described here. Personally I am not a fan of command-line tools so I use MOTODEV plug-in for Eclipse (though you have to register to download it). It has a Database perspective capable of manipulating your SQLite db.

slkorolev
  • 5,883
  • 1
  • 29
  • 32
1

Open Eclipse Go To Window > Showview > Other.. > File Expolrer Click On Open

Now Go To

data/data/your.package.name/databases/<DATABASE FILE Here >

Now Click On Pull File From Device Which Is Right Side On Top

Save That File To Anywhere In Your PC Then

Use the SQLite database browser to explore stored data.

Guru
  • 644
  • 6
  • 18
WeNeigh
  • 3,489
  • 3
  • 27
  • 40
0

Use third party library developed by facebook 'stetho', Follow th document

Muneesh
  • 433
  • 10
  • 19
0

You have a couple of choices:

  1. While the emulator is running, inside Eclipse, go to Window -> Show View -> Other.. -> Android -> File Explorer and then data/data/(Search your App_name)/databases
  2. Copy the db to the sd card, move it to your computer and view it there. For code to do this, see one of my other posts here: Is it possible to save database file to SD card?

For #1, don't forget that the emulator needs to be running. For #2, I've found that the SQLite Manager for Firefox is a great tool for viewing the db.

Community
  • 1
  • 1
SBerg413
  • 14,515
  • 6
  • 62
  • 88
  • Thanks, I found the database using the first option, but all it tels me is that it's there. There are 2 items, on has my database's name and size of 5120, the other one is named data and has 0 size (there isn't any data in the database yet) I haven't found a way to open those items and browse the contents. Can that be done? – Shaggydog Oct 13 '11 at 16:54
  • In the the File Explorer view, there is an icon at the upper right hand corner that allows you to pull the file from the emulator and save it. Do that, and then use the SQLite Manager firefox plugin to view it. – SBerg413 Oct 13 '11 at 17:57