1. Create/delete a table
String SQL = "Create table" + TABLE_NAME + "(" + FIELD_ID + "integer primary key autoincrement," + FIELD_TITLE + "text );";
Db.exe cSQL (SQL );
String SQL = "DROP TABLE IF EXISTS" + TABLE_NAME;
Db.exe cSQL (SQL );
Ii. Query
Query data FROM a table (in) SELECT * FROM meta where media_id in (, 9 );
3. insert
SQLiteDatabase db = this. getWritableDatabase ();
ContentValues cv = new ContentValues ();
Cv. put (FIELD_TITLE, Title );
Long row = db. insert (TABLE_NAME, null, cv );
Iv. Update
SQLiteDatabase db = this. getWritableDatabase ();
String where = FIELD_ID + "=? ";
String [] whereValue = {Integer. toString (id )};
ContentValues cv = new ContentValues ();
Cv. put (FIELD_TITLE, Title );
Db. update (TABLE_NAME, cv, where, whereValue );
5. Delete
SQLiteDatabase db = this. getWritableDatabase ();
String where = FIELD_ID + "=? ";
String [] whereValue = {Integer. toString (id )};
Db. delete (TABLE_NAME, where, whereValue );
Author: dylove98