gpt4 book ai didi

android - 如何获取联系人的版本或修改时间?

转载 作者:行者123 更新时间:2023-11-29 18:13:49 28 4
gpt4 key购买 nike

我想弄清楚 Android 联系人中是否有一个属性表明联系人是否已被修改。

我读到可以通过字段 ContactsContract.Contacts.Entity.VERSION 读取联系人的版本,但我无法检索它的值。我总是收到 IllegalArgumentException。

有人知道如何获取联系人的版本,或者是否有其他方法可以查明自上次扫描地址簿以来联系人是否已被修改?

最佳答案

这是代码,我没有测试,因为我工作很忙。

    public void getVersion() {
//specify which fields of RawContacts table to be retrieved.
String[] projection = new String[] {RawContacts.VERSION};

//query the RawContacts.CONTENT_URI
Cursor cur = mContext.getContentResolver().query(RawContacts.CONTENT_URI, projection,null,null,null);

while(cur.moveToNext()){
String version = cur.getString(cur.getColumnIndex(RawContacts.VERSION));
Log.i("VersionRetriever", version);
}

//Always remember to close the cursor. Otherwise it leads to side-effects.
cur.close();

关于android - 如何获取联系人的版本或修改时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9293175/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com