Search This Blog

Wednesday, 28 March 2012

Lita ? and How to access a Android database by using a command line


What is Lita ?
Lita is an administration interface for SQLite databases. It lets you edit your databases structure and data in a dedicated environment.
Lita is a free and open source SQLite database administration tool for Windows, MacOSX and Linux.
Important It is strongly recommended to make backups of your databases on a regular basis. Always assume that Lita can break your database

What is Adobe AIR?

The Adobe® AIR® runtime enables developers to deploy standalone applications built with HTML, JavaScript, ActionScript®, Flex, Adobe Flash® Professional, and Adobe Flash Builder® across platforms and devices — including Android™, BlackBerry®, iOS devices, personal computers, and televisions.
Can I use Lita with non-AIR SQLite databases ?
While most of its features are compatible with any sqlite database, it was primarily designed to administrate AIR application databases. Some field types and features, such as encryption, are AIR only.

Examining sqlite3 Databases from a Remote Shell

From an adb remote shell, you can use the sqlite3 command-line program to manage SQLite databases created by Android applications. The sqlite3 tool includes many useful commands, such as .dump to print out the contents of a table and .schema to print the SQL CREATE statement for an existing table. The tool also gives you the ability to execute SQLite commands on the fly.
To use sqlite3, enter a remote shell on the emulator instance, as described above, then invoke the tool using the sqlite3 command. Optionally, when invoking sqlite3 you can specify the full path to the database you want to explore. Emulator/device instances store SQLite3 databases in the folder /data/data/<package_name>/databases/.
Here's an example:
$ adb -s emulator-5554 shell
# sqlite3 /data/data/com.example.google.rss.rssexample/databases/rssitems.db
SQLite version 3.3.12
Enter ".help" for instructions
.... enter commands, then quit...
sqlite> .exit 
Once you've invoked sqlite3, you can issue sqlite3 commands in the shell. To exit and return to the adb remote shell, use exit or CTRL+D.

Tutorial : How to access a Android database by using a command line.

When your start dealing with a database in your program, it is really important and useful to be able to access it directly, outside your program, to check what the program has just done, and to debug.

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;

DOS and Linux Command for checking databaase and table
comments


->cd Desktop //the place were your program is present
->cd android_sdk_Linux_x86
->cd platform_tools
->./adb
->./adb -s emulator-5554 shell //name of the emulator
->#sqlite3 /data /data/mina.android Database Demo/databases/demoDB
->.table

//to ilist table
-> select * from tablename;

------------------------------------------------------------------------------------------------------------------------

http://androidblogger.blogspot.in/2009/06/tutorial-how-to-access-android-database.html

No comments:

Post a Comment