获取Android 2.1的联系人生日字段


获取有生日信息的联系人的生日字段:

ContentResolver cr = getContentResolver();
    Uri uri = ContactsContract.Data.CONTENT_URI;
    String [] projection = new String[]{Event.DATA1};
    String selection = Data.MIMETYPE+"='"+Event.CONTENT_ITEM_TYPE+"'"+" and "+Event.TYPE+"='"+Event.TYPE_BIRTHDAY+"'";
    Cursor cursor = cr.query(uri, projection, selection, null, null);
    List<Contacts> listcontacts = new ArrayList<Contacts>();
    if(cursor!=null){
        if(cursor.moveToFirst()){
            do{
                Contacts contacts = new Contacts();
                contacts.setBirthday(cursor.getString(0));
                listcontacts.add(contacts);
            }while(cursor.moveToNext());
        }
    }
    return listcontacts;

 

  • 1
  • 2
  • 下一页

相关内容