I'm using the code below to retrieve a cursor for events and contacts and it's working just fine for events with a year specified. Unfortunately, events where only the day and month are set are not returned by this query.
I have set these dates in Google Contacts for some contact birthdays and I'm wondering if I need to use RawContacts rather than ContactsContract to get these values?
Update: It seems that events entered into the phone without a year are retrieved. It is only events added via http://www.google.com/contacts that are not retrieved. I can see these events in the Contacts app though - displayed as something like --05-23
.
String[] projection = new String[] {
ContactsContract.Contacts._ID,
ContactsContract.Contacts.DISPLAY_NAME,
Event.CONTACT_ID,
Event.START_DATE,
Event.TYPE
};
Cursor c = mContext.getContentResolver().query(
ContactsContract.Data.CONTENT_URI,
projection,
ContactsContract.Data.MIMETYPE + "= ?",
new String[] { Event.CONTENT_ITEM_TYPE },
Event.START_DATE);
c.moveToFirst();
int nameIndex = c.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME);
int dateIndex = c.getColumnIndex(Event.START_DATE);
String name, date;
while (c.moveToNext()) {
name = c.getString(nameIndex);
date = c.getString(dateIndex);
Log.d(TAG, "Event for " + name + " is " + date);
}
c.close();