I use the code below to get the cursor for events and contacts, and it works great for events with the specified year. Unfortunately, events when only the day and month are specified are not returned by this request.
I set these dates in Google Contacts for some birthdays of the contact, and I wonder if I need to use RawContacts instead of ContactsContract to get these values?
Refresh . It appears that data entered into the phone without using a year is retrieved. Only events added through http://www.google.com/contacts that are not retrieved. I see these events in the Contacts application, although - it appears 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();
David Snabel-Caunt
source share