sqlite - Android SQLitedatabase -
this question has answer here:
why have move first item in code below? thought cursor contain 1 row since rowid primary key
// fetch single reminder @suppresslint("newapi") public cursor fetchreminder(long rowid) throws sqlexception { cursor mycursor = db.query(true, database_table, new string[] { key_row_id, key_title, key_body, key_date_time }, key_row_id + "=" + rowid, null, null, null, null, null, null); if (mycursor != null) { mycursor.movetofirst(); } return mycursor; }
there 1 cursor class. cannot known how many rows have. query not create different types of cursors querying single row or many. should call:
curcor c = db.query(...); try { if (c.movetofirst()) { // have 1 result. //otherwise iterate //(while(c.movetonext()){...} string value = c.getstring(0); } } { c.close(); }
Comments
Post a Comment