Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Rajab Davudov
What is SQLite?
• SQLite is Open Source Database
embedded into Mobile Devices.
• SQLite supports SQL syntax, transactions
...
SQLite Types
• TEXT (String in Java)
• INTEGER (long in Java)
• REAL (double in Java)
SQLite in Android
• SQLite comes with all Android devices
• Application database is stored at
DATA/data/APP_NAME/databases...
SQLite in Android
• Two packages
– android.database
– android.database.sqlite
SQLiteOpenHelpler
• onCreate()
• onUpgrade()
• getReadableDatabase()
• getWriteableDatabase()
SQLiteDatabase
• insert()
• update()
• delete()
• query()
• rawQuery()
insert()
ContentValues values = new ContentValues() ;
values.put("username", username) ;
values.put("fullname", fullname) ...
query()
Cursor cursor = database.query(
"users",
new String[] {"fullname"},
"username = ? and password = ?",
new String[]{...
rawQuery()
Cursor cursor = database.rawQuery(
"select fullname from users where username = ?
and password = ?",
new String...
Cursor
A Cursor represents the result of a query and
basically points to one row of the query result.
• getCount()
• moveT...
Ready, Steady, Code !!!
Rajab Davudov
Senior Developer at Azerfon
radjab@gmail.com
https://market.android.com/developer?pub=RADJAB
http://gplus.to...
Upcoming SlideShare
Loading in …5
×

Rajab Davudov - Android Database

2,018 views

Published on

Rajab Davudov - Android Database

Published in: Education
  • Be the first to comment

Rajab Davudov - Android Database

  1. 1. Rajab Davudov
  2. 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. 3. SQLite Types • TEXT (String in Java) • INTEGER (long in Java) • REAL (double in Java)
  4. 4. SQLite in Android • SQLite comes with all Android devices • Application database is stored at DATA/data/APP_NAME/databases/FILENAME
  5. 5. SQLite in Android • Two packages – android.database – android.database.sqlite
  6. 6. SQLiteOpenHelpler • onCreate() • onUpgrade() • getReadableDatabase() • getWriteableDatabase()
  7. 7. SQLiteDatabase • insert() • update() • delete() • query() • rawQuery()
  8. 8. insert() ContentValues values = new ContentValues() ; values.put("username", username) ; values.put("fullname", fullname) ; values.put("password", password) ; database.insert("users", null, values) ;
  9. 9. query() Cursor cursor = database.query( "users", new String[] {"fullname"}, "username = ? and password = ?", new String[]{username, password}, null, null, null) ;
  10. 10. rawQuery() Cursor cursor = database.rawQuery( "select fullname from users where username = ? and password = ?", new String[] { username, password }) ;
  11. 11. Cursor A Cursor represents the result of a query and basically points to one row of the query result. • getCount() • moveToFirst() • moveToNext() • …
  12. 12. Ready, Steady, Code !!!
  13. 13. Rajab Davudov Senior Developer at Azerfon radjab@gmail.com https://market.android.com/developer?pub=RADJAB http://gplus.to/radjab http://www.fb.me/rajab.davudov http://www.linkedin.com/in/radjab Market QR Code

×