0

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.

Community
  • 1
  • 1
sarveshs
  • 68
  • 1
  • 2
  • 9

1 Answers1

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