如何更新通话记录中的条目内容?
我想将 Android 呼叫日志中第一个条目的 CallLog.Calls.TYPE
字段从 MISSED
更新为 INCOMING
。我读过书籍,开发人员参考过并用谷歌搜索过,并且我有理由确信我的代码是正确的。然而,当我实际调用 update()
时,结果是没有记录被更新。我的代码示例如下。
在你提问之前:
- 我拥有 WRITE_CONTACTS
的权限 - 要更新的记录(0)确实存在
- 我已经在 DroidX (Verizon) 和 Samsung Galaxy (AT&T) 上尝试过此操作 - 我已经尝试过此代码的各种其他更长的形式,但结果相同,
有人可以帮忙吗?
ContentValues newValues = new ContentValues();
newValues.put(CallLog.Calls.TYPE, CallLog.Calls.INCOMING_TYPE);
newValues.put(CallLog.Calls.DURATION, 50);
int result = OsmoService.context.getContentResolver().update(
ContentUris.withAppendedId(CallLog.Calls.CONTENT_URI, 0),
newValues,null,null);
I would like to update the CallLog.Calls.TYPE
field of the first entry in the Android Call Log from MISSED
to INCOMING
. I have read books, the developers reference and googled this to death and am reasonably sure that my code is correct. However, when I actually make the call to update()
, the result is that no record is updated. My code sample is below.
Before you ask:
- I have permissions for WRITE_CONTACTS
- The record to be updated (0) does exist
- I have tried this on both a DroidX (Verizon) and a Samsung Galaxy (AT&T)
- I have tried various other, longer forms of this code with same result
Can someone please help with this?
ContentValues newValues = new ContentValues();
newValues.put(CallLog.Calls.TYPE, CallLog.Calls.INCOMING_TYPE);
newValues.put(CallLog.Calls.DURATION, 50);
int result = OsmoService.context.getContentResolver().update(
ContentUris.withAppendedId(CallLog.Calls.CONTENT_URI, 0),
newValues,null,null);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您更新上面的代码并将行: 替换
为此行:
它可以工作。我不知道为什么,内容 URI 有点不正确。
例子:
If you update your code above and replace the line:
with this line:
It works. I don't know why, but something is not correct with the content URI.
example:
例如 CallLog.Calls.CACHED_NAME
for example CallLog.Calls.CACHED_NAME