Raw contact subtable Data Query

Source: Internet
Author: User

Raw_contact subtable query is very interesting.

Raw_contact has many subtables. Mainly include:

Android. provider. contactscontract. commondatakinds. structuredname;

Android. provider. contactscontract. commondatakinds. Phone;

Android. provider. contactscontract. commondatakinds. Email;

Android. provider. contactscontract. commondatakinds. Organization;

We can query in the following form

// Set our expandable list Adapter

String [] projection = new string [] {

Phone. _ id,

Phone. display_name,

Phone. Number,

Phone. raw_contact_id,

};



Cursor contactdata = managedquery (

Phone. content_uri,

Null, // all columns are queried. You can use projection to specify a query.

Null,

Null,

Null );

I used the following statement to print out all the queried column names.

(Note that the same number of columns queried by email indicates that the number of columns in different subtables is the same, but the meaning between data1 and data15 is different)

Int colcount = contactdata. getcolumncount ();

For (INT I = 0; I <colcount; I ++)

Log. I (tag, I + "I:" + contactdata. getcolumnname (I ));

However, the printed columns are much more than I thought. I think phone. content_uri is the "View" concept of the corresponding database.

A total of 55 columns are obtained for query.

I. Data in the sub-table, the 25 columns declared in contactscontract. Data:

Variable name column name remarks

_ Id

Mimetype

Raw_contact_id

Is_primary

Is_super_primary

Data_version

Data1 ~ Data15 data1 ~ Data15

Sync1 ~ Sync4 data_sync1 ~ Data_sync4

 

2. Connect to contactscontract. statusupdates and obtain 6 pieces of data

Variable name column name remarks

The presence mode presence_status variable is also "Mode", but according to the data documentation is presence

The status presence_custom_status variable is also "Mode", but according to the data documentation, it should be status

Status_timestamp status_ts

Status_res_package

Status_label

Status_icon

NOTE 1: In fact, presence_status and presence_custom_status are not included in the columns declared by statusupdates. Of course, it is impossible to be connected.

NOTE 2: statusupdates has a total of 11 data items, but 5 data items are not connected.

They are data_id, protocol, custom_protocol, im_handle, and im_account.


3. Connect the 11 project data obtained by rawcontacts.

Variable name column name remarks

Contact_id

Times_contacted

Last_time_contacted

Starred starred

Custom_ringtone

Send_to_voicemail

Account_name

Account_type

Source_id sourceid

Version Version

Dirty

Note 1: Although rawcontacts has 18 items, it only contains 11 items. Seven other items are not included.

They are _ id, aggregation_mode, deleted, and sync1 ~ Sync4

NOTE 2: rawcontactscolumns defines three project data in total, but only one contact_id is included.

Aggregation_mode and deleted are not included

According to the documents in contactscontract. Data, only contact_id, aggregation_mode, and deleted will be included.

But this is not the case. Why?


4. Connect the nine project data obtained by contacts.

Variable name column name remarks

Lookup_key Lookup

Photo_id

In_visible_group

Contact_presence

Ontact_status contact_status

Contact_status_timestamp contact_status_ts

Contact_status_res_package

Contact_status_label

Contact_status_icon

Note 1: Although rawcontacts has 17 items, it only contains 9 items. Eight other items are not included.

They are: _ id, name_raw_contact_id, display_name_primary, times_contacted,

Last_time_contacted, starred, custom_ringtone, send_to_voicemail

NOTE 2: Both rawcontacts and contacts have a variable name named times_contacted and their column names are "times_contacted ".

Refer to the definition of times_contacted in two classes,

The value of times_contacted in contacts is the maximum value of times_contacted for all rawcontacts in the contacts group.

Therefore, the column named times_contacted obtained by the query should be times_contacted of rawcontacts.

The same applies to last_time_contacted.

NOTE 3: According to the starred definition, the column named starred should be starred of rawcontacts.

Note 4: For custom_ringtone and send_to_voicemail, they are declared in the rawcontacts and contacts columns, and their definitions are the same.

It is not clear from their definition documents.

But here we mainly query rawcontacts. I think they should be from rawcontacts rather than contacts.

Note 5: For times_contacted, last_time_contacted, starred, custom_ringtone, send_to_voicemail

However, according to the contactscontract. data file, they are connected by contacts,

However, through the above analysis, they did not connect to the contact. Instead, it is connected through rawcontacts.


5. Data. groupmembership.

Variable name column name remarks

Group_source_id group_sourceid

This data is obtained by connecting data. groupmembership. But it is not described in this document.

6. Two unknown source data items

Column name remarks

Display_name

Res_package

Note 1: display_name may come from display_name of contactscolumns and from conact.

However, where the display_name of conact comes from the database is puzzle. It may come from display_name_primary.

Why cannot I directly query the display_name_primary of contacts? It is also a puzzle.

NOTE 2: Where does res_package come from? No clue.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.