Christian
Christian

Reputation: 26387

Inspecting android sql database from Eclipse

Is there a way to directly inspect an SQLite3 database in Android via Eclipse or do I have to do this via the shell?

Upvotes: 12

Views: 10619

Answers (4)

Takao Sumitomo
Takao Sumitomo

Reputation: 511

https://github.com/cattaka/TelnetSqlite/wiki

I made it this by following 3 step.

  • Embed a small program
  • Add code to kick the embedded program in the Application.onCreate() method
  • Execute the telnet and run SQL via small program

But it is not from Eclipse. It uses telnet or a sql editor named RdbAssistant.

Upvotes: 0

Gerard Humphries
Gerard Humphries

Reputation: 11

http://sqlitebrowser.sourceforge.net/index.html

This is a simple way of inspecting the contents of a database. Just use the DDMS to pull the database from the device and then open.

Upvotes: 1

Hamy
Hamy

Reputation: 21552

Unfortunately AFAIK you always have to use the shell currently. (Well, not quite. You can use DDMS in Eclipse to pull the database, but that's not much better than using the shell).

Basically you can either 1) pull the database file from the emulator / phone and then inspect it, or you can 2) manually run some SQL queries from inside the emulator/phone.

For 1, I would recommend creating a script. Here is simple example

$ cat android_pull_db 
#!sh
adb shell "chmod 777 /data/data/com.mypackage/databases/store.db"
adb pull /data/data/com.mypackage/databases/store.db 
$ 

To create your own, paste the lines from #!... down to adb pull ... into a text file, and save it somewhere. Modify the package location and database filename. Make it executable, and add it to your path.

For 2, just execute this:

$ adb shell
$ cd /data/data/com.yourpackage/databases
$ sqlite3 your-db-file.db
> .help

Upvotes: 8

Brett
Brett

Reputation: 2635

I don't know if you can inspect it from within eclipse but you can pull a copy of the database file from the DDMS perspective in the file explorer in folder

 data->data->your.package.name->databases

which you can inspect with a free database manager such as sqlite studio

Upvotes: 13

Related Questions