如何在 Kotlin 中编辑联系人的电话号码?
我有一个具有唯一联系人 ID 的联系人数据类,并且想要更改联系人的电话号码。 这是数据类:
data class Contact(
val id : String,
val name : String,
val number : String)
我找到了一个关于如何有目的地执行此操作的教程,但是我想使用 Android 中的 contactProvider 来执行此操作。我已经在清单中声明了 WRITE_CONTACT 权限,但仍然不知道如何将电话号码保存到现有联系人。我在谷歌上也找不到任何好的教程。
I have got a contact data class with the unique contact ID and want to change the phone number of the contact.
Here's the data class:
data class Contact(
val id : String,
val name : String,
val number : String)
I have found a tutorial on how to do this with an intent, however I would like to do this using the contactsProvider in Android. I already have WRITE_CONTACT permissions declared in the manifest, but still don't know on how to save the phone number to an existing contact. I'm also unable to find any good tutrial on Google.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下是一段代码,用于将给定联系人 ID 的当前电话号码更新为新电话号码:
以下是此代码背后的更多说明:https://stackoverflow.com/a/63761333/819355
我会将此问题标记为链接问题的重复项,但链接问题不会有任何接受的答案,所以它不会让我。
Here's a snippet of code that will update a current phone number to a new phone number for a given contact ID:
Here's some more explanation behind this code: https://stackoverflow.com/a/63761333/819355
I would have marked this question as a duplicate of the linked question, but the linked question doesn't have any accepted answer so it won't let me.