And it is important also on Android.
Here is how to do that :
1) Launch the emulator (or connect your real device to your PC ). I usually launch one of my program from Eclipse for this.
2) Launch a command prompt in the android tools directory.
3) type adb shell.
This will launch an unix shell on your emulator / connected device.
4) go to the directory where your database is :
cd data/data
here you have the list of all the applications on your device
Go in your application directory ( beware, Unix is case sensitive !! )
cd com.alocaly.LetterGame
and descend in your databases directory :
cd databases
Here you can find all your databases. In my case, there is only one ( now ) : SCORE_DB
5) Launch sqlite on the database you want to check / change :
sqlite3 SCORE_DB
From here, you can check what tables are present :
.tables
6) enter any SQL instruction you want :
select * from Score;
This is quite simple, but every time I need it, I don't know where to find it.
Great post, thanks for the walkthrough!
ReplyDeleteReally Nice and Step by Step article for connecting to android databases.
ReplyDeletethanks for the post.
Thanks a lot.
ReplyDeleteReally Nice.
I am getting permission denied error, can you help?
ReplyDeleteThanks I really needed this!
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDeleteThank you,
ReplyDeletenice article for connecting to android databases.
thanks it sounds useful.
ReplyDeleteBut can you pls tell me how to take the android tools directory? is it a windows folder?
The tools directory is the tool in the sdk where the Android tools are located ( so, yes, it is a Windows folder ).
ReplyDeleteIn recent SDK, it is located there :
/platform-tools/
I got permission denied, too:
ReplyDelete$ sqlite3
sqlite3: permission denied
$ cd databases
$ ls
opendir failed, Permission denied
$ sudo -s
sudo: permission denied
$ su -
su: permission denied
$
Any suggestions?
answer to the permission denied is i don't think your typing cd
ReplyDeleteBecause if you don't it says that
Nice man!
ReplyDeletePls, do u know how to do suing Nexus S device?
Do I really need to root?
try adb root if u get permission denied
ReplyDeleteBrilliant Post! Very well written..
ReplyDeleteNeha
Thank you very much. It's quite helpful
ReplyDeleteIf cd doesn't work use ls just to list directories. This way you will know where is db. Then use
ReplyDelete>> sqllite3 [here your directories you found use ls command]
sqllite3 data/data/r.nunes.package/databases/Apication.db
Thanks a lot!
ReplyDeleteI'm the same. That's why I'm beginning to collect tutorials/post that I find useful. Thanks.
ReplyDeleteThis comment has been removed by the author.
ReplyDeletevery resourceful..I needed it.thanq so much for sharing..
ReplyDeleteDoesn't work. Get a permission denied error when doing LS to list the files.
ReplyDeleteGetting a command not found error when typing "sqlite3". Running Android Ice Cream sandwich
How to build the sqlite3 binary and library yourself.
ReplyDeleteI have put together some build scripts to compile SQLite for Android Native Code using the Android NDK. It builds the SQLite CLI in two versions: Statically and Dynamically Linked, as well as it's Static and Shared Libraries. You may get the scripts from my GitHub and build the binaries yourself:
https://github.com/stockrt/sqlite3-android
Hope this will be useful for someone.