读取联系人信息

读取联系人信息,用了android自带的PEOPLE.CONTENT_URI,provider.Contacts.CONTENT_URI都不好用,获取不到联系人号码,随后找到Phones.CONTENT_URI才顺利显示。
ContentResolver contentResolver = this.getContentResolver();

        Cursor cursor = contentResolver.query(Phones.CONTENT_URI, null, null,
            null, null);

        Log.e("ray", "" + cursor.getCount());

        if (cursor.moveToFirst())
        {

            long start = System.currentTimeMillis();

            do
            {

                int nameIndex = cursor.getColumnIndex(Phones.DISPLAY_NAME);

                int numberIndex = cursor.getColumnIndex(Phones.NUMBER);

                String contactName = cursor.getString(nameIndex);

                String contactNumber = cursor.getString(numberIndex);

                Log.e("ray", "contactName" + contactName + "contactNumber"
                    + contactNumber);

            }
            while (cursor.moveToNext());

            long end = System.currentTimeMillis();

            Log.e("ray", "time  " + (end - start));
        }
        cursor.close();
阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/oMartin1/article/details/46787369
个人分类: Android
上一篇显示Intent和隐式Intent
下一篇读取联系人信息
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭