可以使用一组值和联系人查找性能的自定义联系人字段

发布于 2024-09-02 23:38:50 字数 483 浏览 4 评论 0原文

我很确定根据一些初步研究来做我想做的事情是不可行的,但我认为如果有人知道方法的话,向这里的专家社区询问也没什么坏处。

我想为联系人创建一个自定义字段,用户可以从主联系人应用程序中编辑该字段;但是,应该只允许用户从四个特定值的列表中进行选择。一个简短的字符串值列表是理想的,但具有最小/最大范围的 int 就足够了。

我很想知道这两种方式是否可行,但也想知道在性能方面走这条路是否有意义。更具体地说,是每次收到电话或短信时查找联系人(基于电话号码)还是存储我自己的数据集(包括姓名、号码和自定义字段)以及只是经常在线程中同步联系信息吗?或者在应用第一次运行时同步联系人,然后使用 ContentObserver 注册更改?

这是一个类似的问题,其答案解释了如何添加自定义字段发送给联系人

提前致谢。

I'm pretty sure it's not viable to do what I'd like to based on some initial research, but I figured it couldn't hurt to ask the community of experts here in case someone knows a way.

I'd like to create a custom field for contacts that the user is able to edit from the main Contacts app; however, the user should only be allowed to select from a list of four specific values. A short list of string values would be ideal, but an int with a min/max range would suffice.

I'm interested in knowing if it's possible either way, but also wondering if it make sense to go this route performance wise. More specifically, would it be better to look up a contact (based on a phone number) each time a call or SMS message is received or better to store my own set of data (consisting of name, numbers, and the custom field) and just syncing contact info in a thread every so often? Or syncing contacts the first time the app is run and then registering for changes using ContentObserver?

Here is a similar question with an answer that explains how to add a custom field to a contact.

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

花海 2024-09-09 23:38:50

我不认为您自己的联系人数据集存储在单独的数据库中,因为您显然会遇到同步问题。您可以使用 mimetype 并以您链接的方式针对联系人存储您想要的任何内容。

每当您想要循环联系人时,您都可以使用自定义 mimetype 来实现。您获取联系人 ID(来自 ContactsContract.Data.CONTENT_URI),然后运行另一个查询来获取联系人详细信息(来自 ContactsContract.Contacts.CONTENT_URI)。请注意这些是不同的表。

我想为联系人创建一个自定义字段,用户可以从主联系人应用中编辑该字段

,当您使用自定义 mimetypes 时,我认为不可能从主应用程序编辑该字段,并且您在这里没有太多选择。主联系人应用程序将仅显示 SDK 中的字段。您可以存储联系人的详细信息,但它们不会显示在内置的编辑联系人屏幕中。

I don't see the purpose to have your own set of data against contacts stored in your separate database, as you obviously will run into sync issues. You can use the mimetype and store whatever you want against the contact, in the manner you linked.

Whenever you want to looup contacts you can do that by using your custom mimetype. You get the contact id (from ContactsContract.Data.CONTENT_URI), and then you run another query to get the contact details (from ContactsContract.Contacts.CONTENT_URI). Please note these are different tables.

I'd like to create a custom field for contacts that the user is able to edit from the main Contacts app

I don't see that possible, editable from the main app, when you use your custom mimetypes, and you don't have much options here. The main contact app will display only the fields that are in SDK. You can store details against contacts but they won't show up in the inbuilt edit contact screen.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文