我指的是DIRECTORY。为了获得更好的结果,我希望使用ContactsContract.Contacts.Entity URI。APi级别为11,我的设备OS为4.0。我正在使用下面的代码。下面是我在日志中得到的例外。请建议我可以以何种方式使用ContactsContract.Contacts.Entity API。
由: content://com.android.contacts/contacts/entities:URI:引起的
Cursor phones=null;
ContentResolver cr = getContentResolver();
Uri phoneuri = Contacts.CONTENT_URI;
Uri phone_uri = phoneuri.withAppendedPath(phoneuri, ContactsContract.Contacts.Entity.CONTENT_DIRECTORY);
phones = cr.query(phone_uri, null, null, null, null);
for(int i=0;i<phones.getCount();i++)
{
Log.e("int","f_name="+phones.getColumnName(i));
}
phones.close();发布于 2012-09-14 10:47:02
使用此代码可以从android获取所有联系人:
ContentResolver cr = getContentResolver();
String[] projection = { ContactsContract.Contacts.DISPLAY_NAME,
ContactsContract.Contacts._ID };
Cursor contacts = cr.query(ContactsContract.Contacts.CONTENT_URI,
projection, null, null, "UPPER("
+ ContactsContract.Contacts.DISPLAY_NAME + ") ASC");
startManagingCursor(contacts);希望这能帮到你。
发布于 2015-11-26 02:58:03
int contactId = 111;//one contact's id
Uri contactsUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
Uri entityUri = Uri.withAppendedPath(contactsUri, Contacts.Entity.CONTENT_DIRECTORY);
Cursor c = getContentResolver().query(entityUri,
null,null, null, null);https://stackoverflow.com/questions/12422834
复制相似问题