我正在努力从用户个人资料中读出phone/numbers
等。
我有一些以前的代码来读取联系人并通过调整内容uri使其适应用户配置文件。这个名字有用:
普通联系人:
Uri uri = ContactsContract.RawContactsEntity.CONTENT_URI;
String[] projection = new String[] {
ContactsContract.RawContactsEntity.CONTACT_ID,
ContactsContract.RawContactsEntity.MIMETYPE,
ContactsContract.RawContactsEntity.DATA2 };
String selection = ContactsContract.RawContactsEntity.CONTACT_ID
+ " = ? AND " + ContactsContract.RawContactsEntity.MIMETYPE
+ " = ?";
String[] selectionArgs = new String[] {
"" + this.id,
ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE };
...
cursor = cr.query(uri, projection, selection, selectionArgs, null);
通过将uri更改为ContactsContract.RawContactsEntity.PROFILE_CONTENT_URI
我设法使之前的代码也适用于用户个人资料联系人。
但是,在尝试读取电话号码时,这不起作用:
旧代码:
Uri uri = ContactsContract.Data.CONTENT_URI;
String[] projection = new String[] { ContactsContract.Data._ID,
ContactsContract.Data.MIMETYPE, ContactsContract.Data.DATA1,
ContactsContract.Data.DATA2 };
String selection = ContactsContract.Data.RAW_CONTACT_ID + " = ? AND "
+ ContactsContract.Data.MIMETYPE + " = ?";
String[] selectionArgs = new String[] { "" + this.rawContactID,
ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE };
...
cursor = cr.query(uri, projection, selection, selectionArgs, null);
那么我可以将哪个uri用于配置文件呢?我真的找不到任何东西。