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());
//결과 : [01011112222, 01033334444, 01055556666]
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;
}

2011/12/06 11:24 2011/12/06 11:24

Trackback Address :: 이 글에는 트랙백을 보낼 수 없습니다