Here is a simple example:
public boolean containsId(Long userid) {
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery("select * from " + getTableName() + " where id = " + userid, null);
boolean rows = cursor.getCount() > 0;
db.close();
return rows;
}
I thought sqlite automatically starts a transaction. My colleague said I must always start a transaction.
So what is the right pattern? Should I start a transaction if I read data from database? I am sure that no other thread will write at this time in this table.
0 comments:
Post a Comment