使用下面的代码,我可以检查一行是否包含单个字符串(字符串 a),但我将如何检查一行是否等于任一字符串(字符串 a 或 b)?
public Cursor fetchMyList() {
String[] columns = { KEY_ROWID, KEY_CATEGORY, KEY_SUMMARY,
KEY_DESCRIPTION, KEY_EMAIL };
String selection = "description=?";
String a = "blue";
String b = "red";
String[] selectionArgs = { a };
// String[] selectionArgs = { a , b}; ///tried this dont work!!
Cursor cursor = null;
try {
cursor = database.query(DATABASE_TABLE, columns, selection,
selectionArgs, null, null, null);
} catch (Exception e) {
e.printStackTrace();
}
int numberOfRows = cursor.getCount();
if (numberOfRows <= 0) {
return cursor;
}
return cursor;
}