1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | String[] addressInfo = { ContactsContract.CommonDataKinds.Phone.CONTACT_ID, ContactsContract.CommonDataKinds.Phone.NUMBER, ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME }; Uri uri = ContactsContract.CommonDataKinds.Phone.CONTENT_URI; // 한글/영문/숫자및특수문자 순으로 정렬 String sortOrder = "case" + " when substr(" + ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME + ", 1, 1) BETWEEN 'ㄱ' AND '힣' then 1 " + " when substr(" + ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME + ", 1, 1) BETWEEN 'A' AND 'Z' then 2 " + " when substr(" + ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME + ", 1, 1) BETWEEN 'a' AND 'z' then 3 " + " else 4 end, " + ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME + " COLLATE LOCALIZED ASC"; Cursor contactCursor = context.getContentResolver().query(uri, addressInfo, null, null, sortOrder); List<ContactVO> _list = new ArrayList<>(); if (contactCursor != null) { while (contactCursor.moveToNext()) { String phoneNum = contactCursor.getString(1); String name = contactCursor.getString(2); } contactCursor.close(); } | cs |
ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME + " COLLATE LOCALIZED ASC"
만 추가하면 숫자/한글/영문 순으로 정렬된다.
하여 한글/영문/숫자 순으로 정렬하기 위해서 위 소스처럼 case문으로 처리해야한다.
android App 알림 허용 상태 값 가져오기 (0) | 2018.02.20 |
---|---|
Android Log 표시(Log 짤림 현상 개선) (0) | 2017.12.04 |
android Status Bar 색상 변경 (0) | 2017.09.05 |
android 단말기내 어플리케이션(앱) 설치 여부 확인 방법 (0) | 2016.12.05 |
android '최근 실행 목록'에서 실행 시 구분 (0) | 2016.12.05 |
댓글 영역