How to find and collect all the information available in a give contact in any android phone? -


currently displaying contacts of phone in app custom recyclerview. till showing name, mobile number , profile image of contact on list item view need information contact , display when list item of app clicked in custom detail page.

for each contact there different set of information available, in few contacts have email few contacts not present.

my questions are

  1. how can information of given contact without missing single bit.is there structure can traverse , check value each key?

  2. also when populating system contacts in apps list, find same contact multiple times in list. think due fact in device's account manager same number registered many accounts whatsapp, gmail. if how display number once in list.

here can . have contact id base on can save details phone numbers ,emails in custom object , use object display details

custom class like::

class contact{ int contactid; string name; arraylist<phone> phone; arraylist<email> emails; }  class phone{ string phonetype; string number;  }  class email{ string type; string emailid;  } 

retieve detail , add custom class:

contentresolver cr = getcontentresolver();     cursor cursor = cr.query(contactscontract.contacts.content_uri, null,         "display_name = '" + name + "'", null, null);     if (cursor.movetofirst()) {         string contactid =             cursor.getstring(cursor.getcolumnindex(contactscontract.contacts._id));         //         //  phone numbers.         //         cursor phones = cr.query(phone.content_uri, null,             phone.contact_id + " = " + contactid, null, null);         while (phones.movetonext()) {             string number = phones.getstring(phones.getcolumnindex(phone.number));             int type = phones.getint(phones.getcolumnindex(phone.type));             switch (type) {                 case phone.type_home:                     // home number here...                     break;                 case phone.type_mobile:                     // mobile number here...                     break;                 case phone.type_work:                     // work number here...                     break;                 }         }         phones.close();         //         //  email addresses.         //         cursor emails = cr.query(email.content_uri, null,             email.contact_id + " = " + contactid, null, null);         while (emails.movetonext()) {             string email = emails.getstring(emails.getcolumnindex(email.data));             int type = emails.getint(emails.getcolumnindex(phone.type));             switch (type) {                 case email.type_home:                     // home email here...                     break;                 case email.type_work:                     // work email here...                     break;             }         }         emails.close();     }     cursor.close(); 

hope help


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -