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.
22 comments:
Great post, thanks for the walkthrough!
Really Nice and Step by Step article for connecting to android databases.
thanks for the post.
Thanks a lot.
Really Nice.
I am getting permission denied error, can you help?
Thanks I really needed this!
Thank you,
nice article for connecting to android databases.
thanks it sounds useful.
But 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 ).
In recent SDK, it is located there :
/platform-tools/
I got permission denied, too:
$ 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
Because if you don't it says that
Nice man!
Pls, do u know how to do suing Nexus S device?
Do I really need to root?
try adb root if u get permission denied
Brilliant Post! Very well written..
Neha
Thank you very much. It's quite helpful
If cd doesn't work use ls just to list directories. This way you will know where is db. Then use
>> sqllite3 [here your directories you found use ls command]
sqllite3 data/data/r.nunes.package/databases/Apication.db
Thanks a lot!
I'm the same. That's why I'm beginning to collect tutorials/post that I find useful. Thanks.
very resourceful..I needed it.thanq so much for sharing..
Doesn't work. Get a permission denied error when doing LS to list the files.
Getting a command not found error when typing "sqlite3". Running Android Ice Cream sandwich
How to build the sqlite3 binary and library yourself.
I 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.
Post a Comment