How to access a Android database by using a command line.
Many of us uses databases in android applications, So it is very important to know how it is store, where it is store in the device and how to access that database directly outside from your program. That is helpful to understand whether our database code working as per expectation.
Steps to do that:
1) You need to launch the emulator first. Better launch your database application from Eclipse. ( Note: Even you can connect your real device to your PC for this. )
2) Launch a command prompt in the android platform-tools directory. ( Directory which has adb.exe )
3) type adb shell.
This will launch an unix shell on your emulator / connected device.
4) go to the directory where your database is : ( beware, Unix is case sensitive !! )
cd data/data
here you have the list of all the applications on your device
Go in your application directory
cd com.employeedirectory
and descend in your databases directory :
cd databases
Here you can find all your databases.
In my application, there is only one database: employee_directory
5) Launch sqlite on the database you want to check / change :
sqlite3 employee_directory
From here, you can check what tables are present :
.tables
6) enter any SQL instruction you want :
select * from employee;
Don't you think, Those steps are very simple to execute :)
Looks interesting. I must try it out and comeback here to comment more. Believe me that adb is the best tool i have seen ever.
ReplyDeleteGood refreshing, short and sweet; tweet like blog.
Keep it up dude.