query Phone from ContentResolver - Android android.content

Android examples for android.content:ContentResolver

Description

query Phone from ContentResolver

Demo Code


//package com.java2s;

import android.content.ContentResolver;

import android.database.Cursor;

import android.provider.ContactsContract.Data;

import android.provider.ContactsContract.CommonDataKinds.Phone;

public class Main {
    private static final String[] PROJECTION_PHONE = { Data._ID,
            Phone.NUMBER, Phone.TYPE, Phone.LABEL };
    private static final String SELECTION_PHONE = Data.LOOKUP_KEY + "=?"
            + " AND " + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE
            + "'";

    public static Cursor queryPhone(ContentResolver contentResolver,
            String lookupKey) {/* w  w  w .  j av a 2 s.co m*/
        String[] selectionArgs = { lookupKey };
        return contentResolver.query(Data.CONTENT_URI, PROJECTION_PHONE,
                SELECTION_PHONE, selectionArgs, null);
    }
}

Related Tutorials