The previous exercise demonstrate how to "Query Contacts database" for all contacts. To search for contacts with certain constraint in DISPLAY_NAME, we can modify the selection using LIKE cause.
Change:
String selection = ContactsContract.Contacts.DISPLAY_NAME + " IS NOT NULL";
to:
String constraint = "Lau";
String selection = ContactsContract.Contacts.DISPLAY_NAME + " LIKE '%" + constraint + "%'";
![Query Contacts database, search with selection of LIKE cause. Query Contacts database, search with selection of LIKE cause.](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyImSIGpBeoQgDGXXTlqTM7I8hajmK_wUICbcjo1JE-Ro9JYZy2GsmOTy2k9l9PQTJsY7_asCc4OaecWK-knCKJakFvvQSWHICZXhxJDp6qJAqL3MPWHaMisZudNdfZFQ9tXy8EXoDv_Ux/s400/AndroidQueryContacts_03.png)
0 تعليقات