I want to get the contact's(Saved in phonebook) mobile number, work number and home number. I want to set these numbers in my 3 edittext views. How to do this? Here is my code
Cursor phones = getActivity().getContentResolver().query(
Phone.CONTENT_URI, null, Phone.CONTACT_ID + " = " + phoneId,
null, null);
while (phones.moveToNext()) {
number = phones.getString(phones
.getColumnIndex(Phone.NUMBER));
int type = phones.getInt(phones.getColumnIndex(Phone.TYPE));
if (type == Phone.TYPE_HOME) {
number = phones
.getString(phones
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DATA));
return number;
}
if (type == Phone.TYPE_MOBILE) {
number = phones
.getString(phones
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DATA));
return number;
}
if (type == Phone.TYPE_WORK) {
number = phones
.getString(phones
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DATA));
return number;
}
}
0 comments:
Post a Comment