我使用数据库来加密/解密 sqlcipher。现在我编写函数来检查这张卡是否存在于表卡中。当我调试我的方法时,总是返回 false。
public boolean checkIfExistCard(String numberCard, String expirationDate) {
net.sqlcipher.database.SQLiteDatabase db = this.getReadableDatabase(DATABASE_PASSWORD);
Cursor cursor = db.query(CardColumn.CardEntry.TABLE_CARD,
new String[]{CardColumn.CardEntry.CARD_NUMBER, CardColumn.CardEntry.CARD_EXPIRATION_DATA},
CardColumn.CardEntry.CARD_NAME + " = ? and " + CardColumn.CardEntry.CARD_EXPIRATION_DATA + " = ?",
new String[]{numberCard, expirationDate},
null, null, null, null);
if (cursor != null) {
if (cursor.getCount() > 0) {
cursor.close();
db.close();
return true;
}
cursor.close();
db.close();
}
return false;
}