'Query using where condition in Android

I want to set a query to get names which cointain the a particular string (here constraint). SO I coded:

Cursor contactCursor = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, new String[]{Phone.DISPLAY_NAME}, Phone.DISPLAY_NAME + "like + ?", new String[]{"%"+constraint+"%"}, Phone.DISPLAY_NAME + " ASC");

But I get en error. I know that I'm close. Where I'm wrong?



Solution 1:[1]

You have a simple typo. Change this:

"like + ?"

to this:

" like ?"

(add a space in the front and remove the +).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1