ArrayList<string> phone =
new
ArrayList<string>();
Cursor cursor = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
null
,
null
,
null
,
null
);
while
(cursor.moveToNext())
{
int index = cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER);
String s = cursor.getString(index);
phone.add(s);
}
Log.e(
"#####"
, phone.toString());
public static Map<String, String> getAddressBook(Context context)
{
Map<String, String> result =
new
HashMap<String, String>();
Cursor cursor = context.getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
null
,
null
,
null
,
null
);
while
(cursor.moveToNext())
{
int phone_idx = cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER);
int name_idx = cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME);
String phone = cursor.getString(phone_idx);
String name = cursor.getString(name_idx);
result.put(name, phone);
}
return
result;
}
Trackback Address :: 이 글에는 트랙백을 보낼 수 없습니다