I’m attempting to update a row using:
myDatabase.update(DATABASE_TABLE, cvUpdate, KEY_NAME + "=" + mName, null);
but I get the following error:
ERROR/Database(282): Error updating persons_name=Bob using UPDATE peopleTable SET persons_name=? WHERE persons_name=Bob
I am using the following code to attempt the update:
public void updateEntry(String mName) throws SQLException {
ContentValues cvUpdate = new ContentValues();
cvUpdate.put(KEY_NAME, mName);
ourDatabase.update(DATABASE_TABLE, cvUpdate, KEY_NAME + "=" + mName, null);
}
I have looked at other answers which seem to be similar to this problem but I have not found something definitive that solves the problem which I am having. It appears to be something to do with the variables but I may be completely wrong..
You’re not enclosing your string in quotes. You’re better off doing something like this:
when you use the above, it will automatically enclose the param in single-quotes if the type is a string.