【问题标题】:How to get rawcontact id with contact id and lookup key如何使用联系人 id 和查找键获取 rawcontact id
【发布时间】:2015-12-12 19:14:24
【问题描述】:

我正在尝试使用存储在应用程序中的查找键和联系人 ID 从联系人提供程序获取 rawcontacts._ID。

这个函数可能对我有帮助,但我不确定如何构造 rawContactUri

public static Uri getContactLookupUri(ContentResolver 解析器,Uri rawContactUri)

为给定 ContactsContract.RawContacts 条目的父 ContactsContract.Contacts 条目构建 CONTENT_LOOKUP_URI 样式 Uri。

【问题讨论】:

    标签: android contactscontract rawcontacts


    【解决方案1】:
        ContentResolver cr = getBaseContext()
                        .getContentResolver();
                Cursor cur = cr
                        .query(ContactsContract.Contacts.CONTENT_URI,
                                null,
                                null,
                                null,
                                null);
    
                if (cur.getCount() > 0) {
    
                    Log.i("Content provider", "Reading contact  emails");
    
                    while (cur
                            .moveToNext()) {
    
                        String contactId = cur
                                .getString(cur
                                        .getColumnIndex(ContactsContract.Contacts._ID));
                          }
                 }
    

    【讨论】:

    • 我已经有联系人 ID 和来自 contacts.content_uri 的查找键,我使用它来查找原始联系人以防 ID 已更改
    猜你喜欢
    • 1970-01-01
    • 2012-02-03
    • 2015-11-02
    • 2012-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多