2012-04-23 2 views
0

저는 안드로이드 폰에서 연락처를 추출하고 별도의 데이터 스토리지로 옮겨서 내 앱에 표시하는 방법을 보여주는 샘플 프로젝트를 찾고 많은 검색을 해왔습니다. 어떤 사람이 나를 도와 줄 수, .....Android 연락처 이슈

+1

을 얻을하시기 바랍니다? –

+0

중복 가능 : http://stackoverflow.com/questions/9650750/how-to-get-mobile-number-form-contact & http://stackoverflow.com/questions/3476957/where-to-store-a- 연락처 목록에있는 안드로이드 폰 –

답변

0

방법은 연락처 만 이름을 필요 dB 접촉에서

public List<String> lookupContactNames(){ 
    contentResolver = context.getContentResolver(); 
    List<String> contacts = new ArrayList<String>(); 
    Cursor cursor = null; 
    try { 
     final String[] projection = new String[] { ContactsContract.Contacts.DISPLAY_NAME }; 
     String selection = ContactsContract.Contacts.IN_VISIBLE_GROUP 
       + " = '1'"; 
     String[] selectionArgs = null; 
     final String sortOrder = ContactsContract.Contacts.DISPLAY_NAME 
       + " COLLATE LOCALIZED ASC"; 
     cursor = contentResolver.query(
       ContactsContract.Contacts.CONTENT_URI, projection, 
       selection, selectionArgs, sortOrder); 

     while (cursor.moveToNext()) { 
      contacts 
        .add(cursor 
          .getString(cursor 
            .getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME))); 
     } 
     return contacts; 
    } finally { 
     if (cursor != null) { 
      cursor.close(); 
     } 
    } 

}