1. 程式人生 > >用PhoneLookup進行電話號碼查詢

用PhoneLookup進行電話號碼查詢

 public static final class
ContactsContract.PhoneLookup
extends Object
implements BaseColumns ContactsContract.ContactOptionsColumns ContactsContract.ContactsColumns ContactsContract.PhoneLookupColumns
java.lang.Object
        android.provider.ContactsContract.PhoneLookup
Class Overview
A table that represents the result of looking up a phone number, for example for caller ID.
To perform a lookup you must append the number you want to find to CONTENT_FILTER_URI. 
This query is highly optimized. 

電話號碼的查詢可以用如下方式實現。
String phoneNumber="1367890660";
Uri uri = Uri.withAppendedPath(
PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber));
c=context.getContentResolver().query(uri, null,null,null,null);

能查詢到的資訊共14項
Columns
PhoneLookup
long     _ID     read-only     Data row ID.
String     NUMBER     read-only     Phone number.
String     TYPE     read-only     Phone number type. See ContactsContract.CommonDataKinds.Phone.
String     LABEL     read-only     Custom label for the phone number. See ContactsContract.CommonDataKinds.Phone.

Columns from the Contacts table(ContactsContract.Contacts)are also available through a join.
Join with Contacts
String     LOOKUP_KEY
String     DISPLAY_NAME
long     PHOTO_ID
int     IN_VISIBLE_GROUP
int     HAS_PHONE_NUMBER
int     TIMES_CONTACTED
long     LAST_TIME_CONTACTED
int     STARRED
String     CUSTOM_RINGTONE
int     SEND_TO_VOICEMAIL
注意查詢到的資訊項都標記為只讀的。我想這裡的查詢應該就是呼叫的資料庫中儲存過程。
從邏輯上來講就是隻讀的。所以系統在這裡就把標記為只讀的了。