简体   繁体   English

通过SQL加入Android联系人表/数据库?

[英]Joining Android contact tables/databases by SQL?

I need to get all contacts on a phone and their associated phone numbers, therefore I need to join some of the contact tables that Android stores in its internal contacts.db. 我需要获取电话上的所有联系人及其关联的电话号码,因此,我需要将Android存储在其内部contact.db中的某些联系人表进行联接。 I think just joining the data by an SQL statement would be much easier than going with all that content provider stuff, or is there any way to join data on those? 我认为仅通过SQL语句连接数据比处理所有内容提供者的东西容易得多,或者有什么方法可以连接那些数据提供者? Also, if I write an SQL statement, are there any constants for the table names and fields, so that I can keep the query at least a little bit generic, so it won't break on the next Android update, in case they change a table name? 另外,如果我编写一条SQL语句,表名和字段是否存在任何常量,以便我可以使查询至少保持一点通用,以便在下次Android更新时不会中断,以防它们更改表格名称? Thanks for any hint! 感谢您的提示!

You could write your own content provider to do the join , but there you would use your own SQL query anyway. 您可以编写自己的内容提供程序来进行联接,但是无论如何,您都可以在其中使用自己的SQL查询。

The built-in contact providers have several documented column names . 内置联系人提供程序具有多个记录的列名
The table names appear to be an implementation detail, but if they ever change, it's likely that the semantics will change too, so your custom queries would break anyway. 表名似乎是实现细节,但是如果表名更改,则语义也可能会更改,因此自定义查询无论如何都会中断。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM