Whatsapp stores its contacts in the ContactsContract.Data table. For each Whatsapp contact it stores two entries in the same table.
The common fields for both records for each contact are:
- account_type = "com.whatsapp"
- contact_id = 123 (Same _ID in ContactsContract.Contacts table)
1. ContactsContract.Data.MIMETYPE
- "vnd.android.cursor.item/vnd.com.whatsapp.profile" (if the record contains phone number).
- "vnd.android.cursor.item/name" (if the record contains contact name).
2. ContactsContract.Data.DATA3
- contains either the name or the phone number depending on the ContactsContract.Data.MIMETYPE
this can be understood with the help of following diagram:
How Whatsapp stores its contacts in Android Phonebook? |
Feel free to post your comments, queries and suggestions. Thanks
Very nice Post .. very well guided to
ReplyDeletealso nice post about how to read whatsup Contact
Can you kindly post code about how one can add his own icon & contact of person like whats up add into our contact list ,
you guided well on how but can you post code for same how exactly one can achive it .
Like if we using contact details to send sms , or call or to send email without intent ot without chooser as whats up does by directly writing into contact. can you post code for same about how to achieve this ..
Thanking you..
Thanks Sandeep for you feedback. To add your own contacts to the device you need the android.permission.WRITE_CONTACTS permission. here is an excellent example. Also don't forget to checkout the official docs.
Delete