The SQL standard specifies that single-quotes in strings are escaped by putting two single quotes in a row.
Example:
INSERT INTO xyz VALUES('5 O''clock');
So use '' at the place of '. like
if(constraint.contains("'")) constraint = constraint.replace("'", "''");
ContactsContract.Contacts.DISPLAY_NAME + " LIKE '"+constraint+"%'"
No comments:
Post a Comment