Android读取联系人的姓名及号码

 

 /**
     *
     * [读取联系人号码 1.6版本]<BR>
     * [功能详细描述]
     */
    public void readContact16()
    {

        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();
    }

你可能感兴趣的:(android,String,null)