[英]Check record exists or not into SQLite Database Table
如何检查记录是否存在ImageName或不存在数据库表中 ,我正在使用下面的代码进行检查?
// Check for Record using ImageName
public boolean Exists(String strImageName) {
SQLiteDatabase db;
db = this.getReadableDatabase(); // Read Data
Cursor cursor = db.rawQuery("select 1 from churchTable where ImageName=%s",
new String[] { strImageName });
boolean exists = (cursor.getCount() > 0);
cursor.close();
return exists;
}
只需将%s
替换为?
所以在那里使用了strImageName
绑定参数:
Cursor cursor = db.rawQuery("select 1 from churchTable where ImageName=?",
new String[] { strImageName });
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.