0% found this document useful (0 votes)
243 views13 pages

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)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
243 views13 pages

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)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Using SQLite in Android Sample App Demo

Sudhir Chhetri

SQLite
Open source database engine Self Contained, Server less, Zero Configuration, Transactional ([Link] Runtime memory - ~ 250 Kb Supports standard SQL syntax

SQLite
Supported Data Types
TEXT INTEGER REAL NULL BLOB

[Link]

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
[Link] [Link]

Classes
SQLiteOpenHelper
To manage database creation, and version management. [Link] [Link]

SQLiteDatabase

To manage SQLite DB [Link] [Link]

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

[Link] [Link]

Sample App
Agenda
To-do List App Insert Select Browse DB using DDMS (Eclipse) Browse DB using [Link] (android tools)

Code / Slides
[Link] Email [Link]@[Link]

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 [Link]


Go to command line Cd into the android-sdk/platform-tools dir. Run [Link] 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
[Link]

Android SQLite
[Link]

Android SQLite Database & Content Providers


[Link]

SQLite Crash Course for Android Developer


[Link]

SQLite Administrator
[Link]

OrmLite
[Link]

Thank You !!

You might also like