Reputation: 4984
I am developing an android application. I want to extract information (e.g secondary phone number of home or office) from contacts. Any suggestions?
Upvotes: 1
Views: 278
Reputation: 3590
You will need run a query for all phones..
Cursor phones = cr.query(Phone.CONTENT_URI, null, Phone.CONTACT_ID + " = " + id, null, null);
try {
phones.moveToFirst();
while (!phones.isAfterLast()) {
ContactPhone phone = new ContactPhone();
String number = phones.getString(phones.getColumnIndex(Phone.NUMBER));
// 0 = false | 1 = true
int primary = phones.getInt(phones.getColumnIndex(Phone.IS_PRIMARY));
int type = phones.getInt(phones.getColumnIndex(Phone.TYPE));
//Do whatever you want with this info
phones.moveToNext();
}
} finally {
if (phones != null) {
phones.close();
}
}
Upvotes: 1