Query Contacts database, selection with AND to combine more cause.

The previous exercise demonstrate how to "Query Contacts database" for all contacts, "Search for contacts with phone number only" and "Search with selection of LIKE cause". To combine both cause to search for contacts has phone number with certain constraint in DISPLAY_NAME, combine both cause with "AND".

contacts has phone number with certain constraint in DISPLAY_NAME


Change:
String selection = ContactsContract.Contacts.DISPLAY_NAME + " IS NOT NULL";

to:
String constraint = "Lau";
String selection =
ContactsContract.Contacts.HAS_PHONE_NUMBER + "=1"
+ " AND "
+ ContactsContract.Contacts.DISPLAY_NAME + " LIKE '%" + constraint + "%'";

thumbnail
Title: Query Contacts database, selection with AND to combine more cause.
Rating: 100% based on 99998 ratings. 10 user reviews.
Post by

Related articles :

0 comments:

Post a Comment

My Blog List

 
Copyright © 2015. About - Web Version - Mobile Version Sitemap - Contact - Privacy