I have a table and I want to update the existing values when the count is greater is 1.
Here is my code :
public int getCount(String clues) {
Cursor c = null;
try {
db = this.getReadableDatabase();
String query = "select count(*) from " + TABLE_NAME + "where CLUES_VALUES = ?";
c = db.rawQuery(query, new String[] {clues});
if (c.moveToFirst()) {
return c.getInt(0);
}
return 0;
}
finally {
if (c != null) {
c.close();
}
if (db != null) {
db.close();
}
}
}
I am checking based on the column "CLUES_VALUES" . I am getting the values from database and checking if it contains more than one similar value in the column of "CLUES_VALUES" . If it contains then it will update the entire row else it won't. when I am executing the code, I am getting below error
android.database.sqlite.SQLiteException: near "=": syntax error (code 1): , while compiling: select count(*) from puzzl_tablewhere CLUES_VALUES = ?
Clues_values column contains "String values" I don't know where I am missing. Please help .
Aucun commentaire:
Enregistrer un commentaire