Welcome 微信登录

首页 / 操作系统 / Linux / 获取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;