首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

透过 group id 获得联系人的姓名

2012-09-06 
通过 group id 获得联系人的姓名String where ContactsContract.CommonDataKinds.GroupMembership.GROUP

通过 group id 获得联系人的姓名

String where = ContactsContract.CommonDataKinds.GroupMembership.GROUP_ROW_ID + "="                 + groupid + " AND "                 + ContactsContract.CommonDataKinds.GroupMembership.MIMETYPE + "='"                 + ContactsContract.CommonDataKinds.GroupMembership.CONTENT_ITEM_TYPE + "'";          Cursor c = this.ctx.getContentResolver().query(                 ContactsContract.Data.CONTENT_URI,                 new String[] {                         ContactsContract.CommonDataKinds.GroupMembership.RAW_CONTACT_ID,                         ContactsContract.Data.DISPLAY_NAME                 }, where, null, ContactsContract.Data.DISPLAY_NAME + " COLLATE LOCALIZED ASC"); 

?do {?
? ? if (c.getLong(groupIdx) == id) {?
? ? ? ? Cursor ccur = ctx.getContentResolver().query( Phone.CONTENT_URI,?
? ? ? ? ? ? new String[] {Phone.NUMBER, Phone.TYPE,?
? ? ? ? ? ? Phone.DISPLAY_NAME },?
? ? ? ? ? ? Phone.CONTACT_ID +"="+ contactId, ?
? ? ? ? ? ? ? ? ? null, null); ?
? ? ? ? Log.e("Test: Number", ccur.getString(0))?
? ? ? ? Log.e("Test: Name", ccur.getString(2))?
? ? }?
} while (c.moveToNext());?

热点排行