检索所有与名称过滤器第一个字符有关的联系人

时间:2018-11-15 16:42:07

标签: java android android-contacts

我想检索所有联系人(任何类型,例如Google同步,手机内存,SIM卡等),并从A-Z出现到按联系人姓名的第一个字符过滤的很多部分中

String[] projection = new String[]{
            ContactsContract.Data.CONTACT_ID,
            ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME_PRIMARY,
            ContactsContract.CommonDataKinds.Phone.NUMBER,
            ContactsContract.CommonDataKinds.Phone.NORMALIZED_NUMBER,
            ContactsContract.CommonDataKinds.Phone.STARRED};

    String orderBy = ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME_PRIMARY;
    Uri uri = ContactsContract.CommonDataKinds.Phone.CONTENT_URI;

    String selection = null;
    Cursor cur = null;
    if (mSearchString != null) {
        selection = ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME_PRIMARY + " LIKE '"+ mSearchString +"%'";
        cur = context.getContentResolver().query(uri, projection, selection, null, orderBy);
    }

以某种方式无法正常进行选择,某些Alphabet不显示我的联系人。有人可以帮助我吗?

0 个答案:

没有答案