Contoh query sqlite
public void cekdata() {
SQLiteDatabase db = dbcenter.getReadableDatabase();
SQLiteDatabase sql=dbcenter.getWritableDatabase();
cursor = db.rawQuery("SELECT id_user FROM pesan limit 1", null);
cursor.moveToFirst();
if (cursor.getCount()>0)
{
String returnStringb =cursor.getString(cursor.getColumnIndex("id_user"));
sql.execSQL("update pesan set id_user='"+user.getText().toString()+"'" +
",status='0' where id='1'");
}
else {
sql.execSQL("insert into pesan(id, id_user,status) " +
"values ('1','"+user.getText().toString()+"','0')");
}
cursor.close();
db.close();
}
SQLiteDatabase db = dbcenter.getReadableDatabase();
SQLiteDatabase sql=dbcenter.getWritableDatabase();
cursor = db.rawQuery("SELECT id_user FROM pesan limit 1", null);
cursor.moveToFirst();
if (cursor.getCount()>0)
{
String returnStringb =cursor.getString(cursor.getColumnIndex("id_user"));
sql.execSQL("update pesan set id_user='"+user.getText().toString()+"'" +
",status='0' where id='1'");
}
else {
sql.execSQL("insert into pesan(id, id_user,status) " +
"values ('1','"+user.getText().toString()+"','0')");
}
cursor.close();
db.close();
}