Get contacts from SQL database by certain criteria on Android -


how query contacts matching criteria on android?

let´s say, want have contacts, have name, phone number, no profile picture.

as understand sql thing, need kind of selection, passed query, how in example above?

i´m asking, because i´m running app first queries contacts , after iterate through , filter it, seems less performant querying directly right contacts

you correct in sense contacts stored in sqlite database, accessed via contacts content provider.

the contacts content provider organized in 3 table fashion. @ bottom of data structure lies data table. here find data pertains specific rawcontact (will discuss shortly). data table stores information phone numbers, emails, addresses,etc. using mime name value pairs defined on mimetypes database. 1 level rawcontacts database. here information pertains same account (i.e. contact john doe may have twitter , facebook account). in short, rawcontacts table keeps track of data mime types pertain same person there no need store same information multiple times different accounts. @ top of data structure have contacts table groups information single person. way of unifying account information 1 contact. think of contacts regularly would.

you should take @ loader class allow perform queries on background thread. if use class once implement loader callback cursor, create cursorloader. 1 of constructors parameter typical mysql clause can specify constraints want include part of query.

here find guide loaders query database.


Comments