Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Found the answer after some looking out on the web. The way this has to be done is : </p> <ul> <li>Get list of contacts</li> <li>For each contact, get contactId</li> <li>Get birthday using the contactid</li> </ul> <p>Following is the code snippet : </p> <pre><code>ContentResolver cr = getContentResolver(); //getContnetResolver() String[] projection = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME }; Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, projection, null, null, ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC"); while (cur.moveToNext()) { Map&lt;String, String&gt; contactInfoMap = new HashMap&lt;String, String&gt;(); String contactId = cur.getString(cur.getColumnIndex(ContactsContract.Data._ID)); String displayName = cur.getString(cur.getColumnIndex(ContactsContract.Data.DISPLAY_NAME)); String columns[] = { ContactsContract.CommonDataKinds.Event.START_DATE, ContactsContract.CommonDataKinds.Event.TYPE, ContactsContract.CommonDataKinds.Event.MIMETYPE, }; String where = Event.TYPE + "=" + Event.TYPE_BIRTHDAY + " and " + Event.MIMETYPE + " = '" + Event.CONTENT_ITEM_TYPE + "' and " + ContactsContract.Data.CONTACT_ID + " = " + contactId; String[] selectionArgs = null; String sortOrder = ContactsContract.Contacts.DISPLAY_NAME; Cursor birthdayCur = cr.query(ContactsContract.Data.CONTENT_URI, columns, where, selectionArgs, sortOrder); if (birthdayCur.getCount() &gt; 0) { while (birthdayCur.moveToNext()) { String birthday = birthdayCur.getString(birthdayCur.getColumnIndex(ContactsContract.CommonDataKinds.Event.START_DATE)); } } birthdayCur.close(); } cur.close(); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload