SQLite is an open source SQL database that is embedded into Android devices. It uses very little memory (approx. 250KB) and supports SQL syntax, transactions, and prepared statements. SQLite comes preinstalled on all Android devices and stores application databases in the DATA/data/APP_NAME/databases directory. The android.database and android.database.sqlite packages provide classes for opening databases like SQLiteDatabase and working with SQLite in Android like performing insert, update, delete, and query operations.
2. What is SQLite?
• SQLite is Open Source Database
embedded into Mobile Devices.
• SQLite supports SQL syntax, transactions
and prepared statements.
• SQLite consumes low memory approx.
250Kbyte.
3. SQLite Types
• TEXT (String in Java)
• INTEGER (long in Java)
• REAL (double in Java)
4. SQLite in Android
• SQLite comes with all Android devices
• Application database is stored at
DATA/data/APP_NAME/databases/FILENAME
5. SQLite in Android
• Two packages
– android.database
– android.database.sqlite
9. query()
Cursor cursor = database.query(
"users",
new String[] {"fullname"},
"username = ? and password = ?",
new String[]{username, password},
null, null, null) ;
10. rawQuery()
Cursor cursor = database.rawQuery(
"select fullname from users where username = ?
and password = ?",
new String[] { username, password }) ;
11. Cursor
A Cursor represents the result of a query and
basically points to one row of the query result.
• getCount()
• moveToFirst()
• moveToNext()
• …