/**
* 주소록 리스트 호출
*/
public void getList() {
Uri uri = ContactsContract.CommonDataKinds.Phone.CONTENT_URI;
String[] projection = new String[]{
ContactsContract.CommonDataKinds.Phone.CONTACT_ID,
ContactsContract.CommonDataKinds.Phone.NUMBER,
ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME
};
String[] selectionArgs = null;
// 정렬
String sortOrder = ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME + " COLLATE LOCALIZED ASC";
// 조회해서 가져온다
Cursor contactCursor = null;
try {
// 정보를 담을 array 설정
ArrayList<String> persons = new ArrayList<String>(contactCursor.getCount());
if (contactCursor.moveToFirst()) {
do {
persons.add(contactCursor.getString(2) + "/" +contactCursor.getString(1) + "/" + contactCursor.getString(0)+"/");
} while (contactCursor.moveToNext());
}
tempList = persons;
Log.w("로그확인", String.valueOf(tempList));
Log.w("로그확인", String.valueOf(tempList));
Log.w("로그확인", String.valueOf(tempList));
showList(persons);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (contactCursor != null) {
// contactCursor.close();
// cursor 닫아 버리면 해당 다음 액티비티가 호출되고 다시 넘어가려고 할때 에러가 걸리게 된다 그래서 주석처리
} // end if (contactCursor != null)
} // end try
} // end getList
어탭터를 따로 두어서 리스트뷰에 배열로 사진을 뿌리고 싶은데 다른 예제가 참고가 안되서 헤갈리네요
persons.add(contactCursor.getString(2) + "/" +contactCursor.getString(1) + "/" + contactCursor.getString(0)+"/"); 이부분은 어답터에서 split 나누어서 가져오는 정보로 0 = 이름 1= 전화번호 2 = content id 값 입니다.