Contact .java
public class Contact {
String name ;
String phone;
public Contact() {
}
public Contact(String name, String phone) {
this.name = name;
this.phone = phone;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
@Override
public String toString() {
return "Contact{" +
"name='" + name + '\'' +
", phone='" + phone + '\'' +
'}';
}
}
代码通过uri获取联系人cursor
Uri uri = ContactsContract.CommonDataKinds.Phone.CONTENT_URI;
String name = ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME;
String number = ContactsContract.CommonDataKinds.Phone.NUMBER;
Cursor cursor = getContentResolver().query(uri, new String[]{name, number}, null, null, null);