Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Examining SQLite database of my Android app?

I'm new to Android, I've just gotten to the point where 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). Is there a way I 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. Is there a way to do this? Thanks.

like image 958
Shaggydog Avatar asked Oct 13 '11 14:10

Shaggydog


People also ask

How do I view SQLite database?

Open a command prompt (cmd.exe) and 'cd' to the folder location of the SQL_SAFI. sqlite database file. run the command 'sqlite3' This should open the SQLite shell and present a screen similar to that below.

How do I find my android app database?

Select the Database Inspector tab. Select the running app process from the dropdown menu. The databases in the currently running app appear in the Databases pane. Expand the node for the database that you want to inspect.

Where is the SQLite database stored in Android?

The Android SDK provides dedicated APIs that allow developers to use SQLite databases in their applications. The SQLite files are generally stored on the internal storage under /data/data/<packageName>/databases.


1 Answers

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> 
  • And once it's in my local filesystem, I open it with SQLitebrowser, a nice free Windows graphical client for SQLite. Find more details and download the latest version at http://sqlitebrowser.sourceforge.net and http://sourceforge.net/projects/sqlitebrowser/
like image 176
Guillaume Avatar answered Oct 03 '22 00:10

Guillaume