I am making an android app, and for that app, I need to read the birth dates of the contacts stored in my address book. Is there any code for that. How to read contacts on Android 2.0 shows the code to read the phone numbers and email addresses, but the code to read birth dates is not available. Thanks in advance.
Asked
Active
Viewed 407 times
0
-
http://stackoverflow.com/q/8579883/562935 – tidbeck Jan 30 '12 at 14:02
1 Answers
1
Use the ContactsContract.CommonDataKinds.Event.START_DATE
and set the TYPE
to TYPE_BIRTHDAY
ContactsContract.CommonDataKinds.Event | Android Developers
Uri uri = ContactsContract.Data.CONTENT_URI; String[] projection = new String[] { ContactsContract.Contacts.DISPLAY_NAME, ContactsContract.CommonDataKinds.Event.CONTACT_ID, ContactsContract.CommonDataKinds.Event.START_DATE }; String where = ContactsContract.Data.MIMETYPE + "= ? AND " + ContactsContract.CommonDataKinds.Event.TYPE + "=" + ContactsContract.CommonDataKinds.Event.TYPE_BIRTHDAY; String[] selectionArgs = new String[] { ContactsContract.CommonDataKinds.Event.CONTENT_ITEM_TYPE };

Tomislav Markovski
- 12,331
- 7
- 50
- 72