请问怎么在android里边用字符串变量来查询sqlite数据库中的值呢?
在查询的时候总是没有单引号,导致查询出错,试了好多办法都没有效果
int getIntContentByColumnName(String conditionColumnName,String condition,String resultColumnName){
int the_int_content = 0;
//cursor = db.rawQuery("select "+conditionColumnName+" from wordlib "+" where "+conditionColumnName+"=?",new String[]{condition});
cursor = db.query("wordlib", null, conditionColumnName+" == "+condition, null, null, null, null);
if (cursor.moveToFirst()) {
do {
the_int_content = cursor.getInt(cursor.getColumnIndex(resultColumnName));
} while (cursor.moveToNext());
}
cursor.close();
return the_int_content;
}