我正在获取所有联系人姓名和号码 bur 我只想显示我选择的号码和姓名。
这是返回所有联系人的代码:
ArrayList<String> contactList = new ArrayList<String>();
switch (reqCode) {
case (0):
if (resultCode == Activity.RESULT_OK) {
Uri uri = ContactsContract.CommonDataKinds.Phone.CONTENT_URI;
String[] projection = new String[] {
ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,
ContactsContract.CommonDataKinds.Phone.NUMBER };
Cursor people = getContentResolver().query(uri, projection,
null, null, null);
int indexName = people
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME);
int indexNumber = people
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER);
people.moveToFirst();
do {
String name = people.getString(indexName);
String number = people.getString(indexNumber);
String contact = name + "" + number;
contactList.add(contact);
} while (people.moveToNext());
}
在contactList
我想添加一个数字和一个名字