我需要从联系人中获取联系人姓名和电话号码,并将它们放在两个列表中。使用下面的代码,我可以获得联系人姓名。但是我怎样才能得到电话号码呢?
List<string> contactNames = new List<string>();
List<string> contactNumbers = new List<string>();
Android.Net.Uri uri = ContactsContract.Contacts.ContentUri;
String[] projection = new String[] {
BaseColumnsConsts.Id,
ContactsContract.ContactsColumnsConsts.DisplayName
};
String selection = string.Format("{0} = '{1}'", ContactsContract.ContactsColumnsConsts.InVisibleGroup, show_invisible ? "0" : "1");
String[] selectionArgs = null;
String sortOrder = string.Format("{0} COLLATE LOCALIZED ASC", ContactsContract.ContactsColumnsConsts.DisplayName);
ICursor cursor = ManagedQuery(uri, projection, selection, selectionArgs, sortOrder);
if (cursor.MoveToFirst()){
do
{
contactNames.Add(cursor.GetString(cursor.GetColumnIndex(ContactsContract.Contacts.InterfaceConsts.DisplayName)));
} while (cursor.MoveToNext());
}