Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 662
Christian Avatar asked Jul 20 '10 17:07

Christian


People also ask

How do I view a database in eclipse?

To open the Database Explorer view, select Window->Show view->Other->Data-> Database Explorer. To open the DB Output view, select Window->Show view->Other->Data-> DB Output view.

Where is SQL 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. However, there are no restrictions on creating databases elsewhere.

Can we use SQL database in Android Studio?

Most Android apps need to store data somewhere and the most common way to store data on Android is using a SQLite Database.


Video Answer


2 Answers

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

like image 56
Brett Avatar answered Sep 28 '22 09:09

Brett


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
like image 30
Hamy Avatar answered Sep 28 '22 10:09

Hamy