lundi 28 septembre 2015

How to Use ContentValues and SQLiteOpenHelper to modify sqlite database in Android?

I wrote a rssFeedReader Application and use directly sqliteSyntax to modify database. this is my code:

 database.execSQL database= openOrCreateDatabase("MyDB", MODE_PRIVATE, null);

 database.execSQL("Create TABLE IF NOT EXISTS Press (press_name
 VARCHAR, press_url VARCHAR");

 database.execSQL("INSERT INTO Press VALUES ('Tasnim',
 'http://ift.tt/1FD3sIO');");

 database.execSQL("UPDATE Press press_name ='Tasnim',
 press_url ='http://ift.tt/1FD3vEx?
 d=2&c=1&m=6&alt=Recent%20News');");

 Cursor cursor = database.rawQuery("SELECT * FROM MyTable", null);

 database.close();

and now my question is how can I migrate to SQLiteOpenHelper and ConentValues method to modify database.

Aucun commentaire:

Enregistrer un commentaire