Successfully reported this slideshow.

Android Level 2

854 views

Published on

level 2@android camp @devent 3
Android DataBase SQLite

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Android Level 2

  1. 1. Android Camp Mohamed Ibrahim Mobile Developer Core-Member
  2. 2. Of R ev iew al ui ck ent A Q un dam as e FDa tab
  3. 3. Type of Database in Android● Internal Database like(Sqlite)● External Database like(Content Provider)
  4. 4. URI"File://[package]/[res id]""File://[package]/[res type]/[res name]"
  5. 5. Internal Database● Preferences● Files● SQLite● Network
  6. 6. What is SQLite !  ● SQLite is an open source Database● Supports standard relational Database● Requires only little memory at runtime (250KB)● Support the data types : ○ TEXT ○ INTEGER ○ REAL● SQLite doesnt validate if the types written in in the columns are actually of the definedtype
  7. 7. Why SQLite !! Si ng rce le n sou Fil eO pe less than 250KB Faster no setup or administration
  8. 8. SQLite Architecture● Package ○ android.database.sqlite● SQLiteDatabase ○ insert _ delete _ update _query _ execSQL● SQLiteOpenHelper ○ Create ○ Upgrade ○ open ○ close
  9. 9. Lets CodeNow
  10. 10. SQLiteOpenHelpersubclass of SQLiteDatabase used to create ,upgrade,open and close database. ● constructor parameters ○ Context ○ String name //database name ○ CursorFactory factory // null ○ version //data base versionwe delete all constructor parameters except context but we wrote databasename ,factory and version in the super of SQLiteDatabase● Have 2 basis methods ○ onCreate //create our database and take one parameter //(SQLiteDatabase) ○ onUpgrade //used when we want to add new column or table //it take 3 parameter (SQLiteDatabas,old,new version)
  11. 11. SQLiteDatabase● Exposes methods to manage a SQLite DataBase: ○ insert insert(String tableName,String nullColumnHack,ContentValues values) ○ delete delete(String tableName,String whereClause,String[] whereArgs) ○ update update(String tableName,ContentValues values,String whereClause,String[] whereArgs ) ○ execSQL execSQL(String sql) ○ query query(String tableName, String[] columns,String selection,String[ ] selectionArg,String groupby,String having,String orderBy)
  12. 12. Cursor moveToFirst
  13. 13. Devmix ssion on bout this seWait a rticle awebsite mix.org www.dev
  14. 14. Thanks*__^

×