相关疑难解决方法(0)

在Android中获取收藏联系人

我正在尝试将所有联系人都放在Android联系人的收藏夹列表中.目前,我可以获取所有组ID,包括最喜欢的组ID.但似乎没有联系人将组ID作为最喜欢的组ID.

我正在尝试在每个组中获取所有组ID和联系人.打印完两个列表后,我发现收藏夹的组ID不在联系人列表中

ArrayList<String> favGroupId=new ArrayList<String>();
        final String[] GROUP_PROJECTION = new String[] {
                ContactsContract.Groups._ID, ContactsContract.Groups.TITLE };
        Cursor  cursor = getContentResolver().query(
        ContactsContract.Groups.CONTENT_URI, GROUP_PROJECTION, null,
                null, ContactsContract.Groups.TITLE);

        while (cursor.moveToNext()) {
            String id = cursor.getString(cursor
                    .getColumnIndex(ContactsContract.Groups._ID));
            Log.v("Test",id);

            String gTitle = (cursor.getString(cursor
                    .getColumnIndex(ContactsContract.Groups.TITLE)));

            Log.v("Test",gTitle);
            if (gTitle.contains("Favorite_")) {
                gTitle = "Favorites";
                favGroupId.add(id);
            }
        }
        cursor.close();
Run Code Online (Sandbox Code Playgroud)

favorites android contacts addressbook

14
推荐指数
2
解决办法
9636
查看次数

标签 统计

addressbook ×1

android ×1

contacts ×1

favorites ×1