【问题标题】:need method to compare given name string with names in address book需要将给定名称字符串与地址簿中的名称进行比较的方法
【发布时间】:2011-07-15 05:26:32
【问题描述】:

有没有什么方法可以将给定的字符串与 android 通讯录中的名称进行比较,例如使用 ContactsContract?

【问题讨论】:

    标签: android contacts addressbook android-contacts


    【解决方案1】:

    因为您需要将字符串与每个联系人列表列表进行比较,并将此名称设置在 listArray 之类的集合之一中。这是您可以获取联系人列表名称的代码

    Cursor cursor = getContentResolver().query(
                    ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
                    new String[] { Phone._ID, Phone.DISPLAY_NAME, Phone.NUMBER },
                    null, null, null);
    
        /*  Cursor cursor = getContentResolver().query(
                    ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
                    null,
                    null, null, null);*/
            startManagingCursor(cursor);
            cursor.moveToFirst();
            cursor.getColumnCount();
    //      //          Log.i("CURSOR COLUMN IS ", ""+cursor.getColumnCount());
            for (int i = 0; i < cursor.getCount(); i++) {
                contactName.add(cursor.getString(1));
            //  //        //          Log.i("NAME OF LIST CONTACT", "" + cursor.getString(3));
                cursor.moveToNext();
            }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-16
      • 2011-09-01
      • 2020-02-29
      相关资源
      最近更新 更多