{Access Android Application Database from an Emulator}
If you’re reading this then you probably already know that Android provides full support for SQLite databases. So any database(s) you create will be accessible by name to any class in an Android application, just not outside the application. The Android SDK includes an SQLite 3.0 database tool that allows you to browse table contents, run SQL commands, and perform other useful functions on SQLite databases. Here I would like to share how we can access the SQLite database from an emulator.
Step 1: Create a database-using application:
For example, as follows:
Application: TestDatabase
Package Name: com.android.TestDatabase
Database Name: TestingDatabase
Table Name: TestingTable
Step 2: Launch the application to create a database for the application.
Step 3: Open a command prompt. For example, on Windows, go to Start > Run and type “cmd”
Step 4: Navigate to the tools folder in the Android SDK.
Step 5: Input the following at the command prompt:
d:\android-sdk\tools>adb shell # cd data/data # cd com.android.TestDatabase # cd databases # sqlite3 TestingDatabase; sqlite3 TestingDatabase SQLite3 version x.x.x Enter ".help" for instructions sqlite>
Step 6: From here you can fire your queries.
For example:
sqlite> select * from TestingTable;
Step 7: To exit, press ctrl+c
Step 8: Then you can check the directories inside the folder.
For example, let’s check all the databases created in the folder “databases”
Type:
# cd databases # ls ls TestingDatabase
Thanks for reading, and I hope this helps. If you have any questions about this specific tutorial or any other issues re: coding for Android, drop us a line any time from our contact page!
Nirav Shah
Software Engineer
Sourcebits Tech Pvt Ltd.

Comments
No comments yet.
Add Comment
You must be logged in to post a comment.