未在结果集中获取数据
这里是代码
public boolean isExist(String question_id, String selected_option, String session_id) {
db = this.getReadableDatabase();
Cursor cur = db.rawQuery("SELECT * FROM " + TABLE_TEST_START + " WHERE question_id_test_start = '" +question_id+ "' AND selected_option_test_start = '"+selected_option+"' AND test_start_id = '"+session_id+"'", null);
boolean exist = (cur.getCount() > 0);
Log.d("DATA PRESENT ","DATA CHECK"+exist);
cur.close();
db.close();
return exist;
}
尝试下面的代码,希望可以解决您的问题。
public Cursor isExist(String question_id,String selected_option,String session_id) {
SQLiteDatabase db = this.getWritableDatabase();
return db.rawQuery("SELECT * FROM " +
TABLE_TEST_START + " WHERE " +
question_id_test_start + "=? AND " +
selected_option_test_start + "=? AND " +
test_start_id + "=? ",
new String[] {question_id,selected_option,session_id}
);
}
获得游标值后,您可以检查其是否存在