I am using SQLLiteHelper class to do the database calls in android. I have below code in which basically I am trying to find any instance of old comment and replace with new comment. If I remove single quotes after LIKE then I get this message.
(1) near "%": syntax error
If I keep the single quotes then I get following message. Not sure what I am doing wrong.
Too many bind arguments. 2 arguments were provided but the statement needs 1 arguments.
public int updateComment(String oldComment, String newComment) { ContentValues values = new ContentValues(); values.put(CommentEntry.COLUMN_NAME_COMMENT, newComment); String selection = CommentEntry.COLUMN_NAME_COMMENT + " LIKE '%?%'"; String[] selectionArgs = new String[]{ oldComment }; int count = database.update(CommentEntry.TABLE_NAME, values, selection, selectionArgs); return count; }