In my android application, I read out all the contacts with the following code:
ContentResolver cr = getContentResolver();
Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
if (cur.getCount() > 0) {
while (cur.moveToNext()) {
String id = cur.getString(cur.getColumnIndex(ContactsContract.Contacts._ID));
String name = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
ContentResolver bd = getContentResolver();
String where = Data.RAW_CONTACT_ID+" = "+id+" and "+Data.MIMETYPE+" = "+CommonDataKinds.Event.CONTENT_ITEM_TYPE;
Cursor bdc = bd.query(ContactsContract.Data.CONTENT_URI, null, where, null, null);
if (bdc.getCount() > 0) {
while (bdc.moveToNext()) {
String birthday = bdc.getString(0);
Toast.makeText(getApplicationContext(), id+name+birthday, Toast.LENGTH_SHORT);
}
}
}
}
cur.close();
This is how I tried to read out the birthday event for every single contact. But obviously it doesn't work yet. So how can I read out the contact's date of birth correctly?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…