Debugging Android Application Database using Terminal, ADB, and SQLite3

Following are the steps to debug android application database using terminal and adb.

1. Open Terminal to start debugging your application database.

2. Goto your platform-tools folder under sdk.

Screen Shot 2014-02-08 at 7.55.32 pm

3. Connect to device using adb

I use emulator in this tutorial. To connect to the device, type command “./adb -s <device-name> shell”. You’ll be redirected to the root folder of your device.

Screen Shot 2014-02-08 at 8.00.25 pm

4. Navigate to your database folder.

go to the folder where your database located. The location is in ¬†“data/data/<package-name>/databases/”

Screen Shot 2014-02-08 at 8.13.13 pm

5. Call sqlite3

execute “sqlite3 <database-name>” to launch sqlite3 service

Screen Shot 2014-02-08 at 8.12.07 pm

6. Start playing with your database

You will be able to issue  command to your database using sqlite3. One thing to be noted is that the foreign key restriction is not activated here, so that you are able to add any row to any table.

Screen Shot 2014-02-08 at 8.19.40 pm