getting the Contact's Birthday of a HTC Sense phone

Posted by Pentium10 on Stack Overflow See other posts from Stack Overflow or by Pentium10
Published on 2010-05-04T20:12:43Z Indexed on 2010/05/04 20:18 UTC
Read the original article Hit count: 243

I am not sure, but probably HTC Sense does the following, syncs my Facebook contacts to my phone along with their mobile number and their birthday. This shows well in the agenda and the user panel. But as it turns out it doesn't use the standard SDK way to store the birthdays.

As if I use the following code to get the birthday of a contact it returns NO data for those contacts.

public String getBirthday() {
  if (data.containsKey(BIRTHDAY)) {
   return CRUtils.getString(data, BIRTHDAY);
  } else {
   // read birthday
   Cursor c = ctx.getContentResolver()
     .query(
       Data.CONTENT_URI,
       new String[] { Event.DATA },
       Data.CONTACT_ID + "=" + this.getId() + " AND "
         + Data.MIMETYPE + "= '"
         + Event.CONTENT_ITEM_TYPE + "' AND "
         + Event.TYPE + "=" + Event.TYPE_BIRTHDAY,
       null, null);
   if (c != null) {
    try {
     if (c.moveToFirst()) {
      String s = c.getString(0);
      this.setBirthday(s);
      return s;
     }
    } finally {
     c.close();
    }
   }
   return "";
  }

 }

How can I fix this?

© Stack Overflow or respective owner

Related posts about android

Related posts about android-sdk