Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
An advance contacts query using https://github.com/vestrel00/contacts-android
val contacts = Contacts(context)
.query()
.where(
(Fields.Name.GivenName startsWith "leo") and
((Fields.Email.Address endsWith "gmail.com") or (Fields.Email.Address endsWith "hotmail.com")) and
(Fields.Address.Country equalToIgnoreCase "us") and
((Fields.Event.Date lessThan Date().toWhereString()) and (Fields.Event.Type equalTo Event.Type.BIRTHDAY)) and
(Fields.Contact.Options.Starred equalTo true) and
(Fields.Nickname.Name equalTo "DarEdEvil") and
(Fields.Organization.Company `in` listOf("facebook", "FB")) and
(Fields.Note.Note.isNotNullOrEmpty())
)
.accounts(
Account("jerry@gmail.com", "com.google"),
Account("jerry@myspace.com", "com.myspace"),
)
.include(Fields.Contact.Id, Fields.Contact.DisplayNamePrimary, Fields.Phone.Number, Fields.Phone.NormalizedNumber)
.orderBy(ContactsFields.DisplayNamePrimary.desc())
.offset(0)
.limit(5)
.find()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment