Search code examples
androidandroid-contentproviderandroid-contacts

Accent insensitive query in the contacts provider


I want to make a contacts query where the selection is in the form Phone.DISPLAY_NAME_PRIMARY + " LIKE ?, but I want the search to be accent insensitive.

If I use COLLATE LOCALIZED, it works with the = operator, not with the like.

Android's default contact app somehow manages to do that.


Solution

  • Instead of making a query to ContactsContract.Data.CONTENT_URI and using a "selection", make a query to ContactsContract.Contacts.CONTENT_FILTER_URI where the query is added as an additional path segment.