0% found this document useful (0 votes)
122 views

Using Sqlite in Android Sample App Demo: Sudhir Chhetri

This document discusses using SQLite in an Android sample app. SQLite is an open-source, self-contained database that runs on Android with no configuration needed. It supports common SQL syntax and data types. The document demonstrates how to create a basic to-do list app using SQLite on Android, including inserting, selecting, and browsing the database using the Device Monitor tool in Eclipse or the sqlite3 command line tool. Code examples and references are provided.

Uploaded by

Ajay Bramhe
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
122 views

Using Sqlite in Android Sample App Demo: Sudhir Chhetri

This document discusses using SQLite in an Android sample app. SQLite is an open-source, self-contained database that runs on Android with no configuration needed. It supports common SQL syntax and data types. The document demonstrates how to create a basic to-do list app using SQLite on Android, including inserting, selecting, and browsing the database using the Device Monitor tool in Eclipse or the sqlite3 command line tool. Code examples and references are provided.

Uploaded by

Ajay Bramhe
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

Using SQLite in Android Sample App Demo

Sudhir Chhetri

SQLite
Open source database engine Self Contained, Server less, Zero Configuration, Transactional (http://sqlite.org) Runtime memory - ~ 250 Kb Supports standard SQL syntax

SQLite
Supported Data Types
TEXT INTEGER REAL NULL BLOB

http://www.sqlite.org

SQLite & Android


Available in all Android device No separate setup or administration Embedded in Android Database Dir:
DATA/data/APP_NAME/databases/FILENAME

Android Package
Packages
android.database android.database.sqlite

Classes
SQLiteOpenHelper
To manage database creation, and version management. http://developer.android.com/reference/android/database/sqlite/SQLiteOpen Helper.html

SQLiteDatabase

To manage SQLite DB http://developer.android.com/reference/android/database/sqlite/SQLiteData base.html

Common DB Tasks
Task Create DB Upgrade DB Open DB Close DB Select Method onCreate() onUpgrade() getWritableDatabase() getReadableDatabase() close() query():Cursor Class SQLiteOpenHelper SQLiteOpenHelper SQLiteOpenHelper SQLiteDatabase SQLiteDatabase

Insert
Update Delete
For complete listings, use the links below:

insert():long
update():int delete():int

SQLiteDatabase
SQLiteDatabase SQLiteDatabase

http://developer.android.com/reference/android/database/sqlite/SQLiteOpenHelper.html http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html

Sample App
Agenda
To-do List App Insert Select Browse DB using DDMS (Eclipse) Browse DB using sqlite3.exe (android tools)

Code / Slides
https://wiki.uta.edu/display/serc/CSE-5324+Tools Email sudhir.chhetri@mavs.uta.edu

To-do List App

Todos Id: PK int Item: text Fig: Todos table

Fig: To-do List App

Code

Browse DB from DDMS


From Eclipse,
Go to Window > Open Perspective > Other.. Select DDMS Select File Explorer Tab Browse to data > data > app_name > databases.

Browse DB from sqlite3.exe


Go to command line Cd into the android-sdk/platform-tools dir. Run adb.exe shell command Run sqlite3 <path to the db file> command.
Path to db file: /data/data/<app_name>/databases/<db_name.db> Path is case sensitive

Run <any sql query>

References
SQLite
http://sqlite.org

Android SQLite
http://developer.android.com/reference/android/database/sqlite/package-summary.html

Android SQLite Database & Content Providers


http://www.vogella.de/articles/AndroidSQLite/article.html

SQLite Crash Course for Android Developer


http://mobile.tutsplus.com/tutorials/android/android-sqlite/

SQLite Administrator
http://sqliteadmin.orbmu2k.de/

OrmLite
http://ormlite.com/sqlite_java_android_orm.shtml

Thank You !!

You might also like