Android Contact Database

Source: Internet
Author: User
Tags locale

Reprinted from Http://www.2cto.com/kf/201406/309356.html

The communication record is a 3-tier data storage model, and these three data models are contactscontact.data,contactscontact.rawcontacts,contactscontact.contacts. Corresponds to three tables: data, Raw_contacts, contacts.

1) Contacts table

The table holds all the phone test contacts, one for each contact, and the table holds the contact's ContactID, number of contacts, last contact time, whether it contains a number, whether it is added to the collection, and so on. Contacts is a combination of raw contacts and a contacts can be composed of one or more raw contacts.

2. raw_contacts table

Table saves all created phone contacts, one row for each contact, and a column in the list that identifies whether the contact was deleted, the table holds two Id:rawcontactid and ContactID, and the Contacts table and Raw_contacts table are linked together. This table holds the contact's Rawcontactid, ContactID, number of contacts, time of the last contact, whether it was added to the collection, the name displayed, and the Hanyu Pinyin used for sorting.

3. Data table

The table holds all the information about all the created phone contacts, one row per field, and the table holds two Id:mimetypeid and Rawcontactid, which links the data table to the Raw_contacts table. All information about a contact is saved in columns Data1 through DATA15, and the contents of each column are different depending on the Mimetypeid.

Table data table in contact database contact2.db

Contactscontact.data

_id

Row ID

package_id

mimetype_id

The ID of the mimetype type saved by the current row. 1 is the mailbox, 2 chat account, 3 address, 4 picture; 5 phone number; 6 name; 7 company + position; 8 nickname; 9 belongs group; 10 remark; 11 URL

raw_contact_id

_ID of the Raw_contacts table

Is_primary

Whether it belongs to the Raw_contacts primary entry, "1" true, "0" false

Is_super_primary

Data_version

The version of the data record. Each time the data row changes version rises. This value is monotonically increasing.

Data1 to Data15

Universal Data Columns (information that holds contacts, contact names, contact phone numbers, e-mails, notes, and so on). The meaning of each column is determined by the type of mimetype_id. Data15 the BLOB (binary data) used for storage (storing pictures).

Data_sync1 to

Data_sync4

The universal column used by the synchronization adapter. For example, a photo row can store the URL of an image in the SYNC1, state (not loaded, loaded, loaded incorrectly) in SYNC2, the server-side version number in SYNC3, and the error code in SYNC4.

Contacts table

Contactscontact.contacts

_id

Row ID, we suggest replacing it with Lookup_key

name_raw_contact_id

_ID of the Raw_contacts table

photo_id

Whether it contains a picture. Reference data table _id, in data_id containing the corresponding mime_type_id, according to mime_type_id Content_item_type look up the picture

Custom_ringtone

Ringtone associated with a contact

Send_to_voicemail

Indicator to determine whether a call from this contact is sent to voicemail (1) or (0). When multiple raw_contacts aggregations are being aggregated, this field is automatically calculated: If all the aggregated raw_contacts are set send_to_voicemail=1, then this field is set to ' 1 '. Setting this field automatically changes the corresponding fields of all aggregated raw_contacts.

times_contacted

Number of contacts with this contact

last_time_contacted

Time of last contact

Statrred

is a common contact; Yes (1), no (0)

In_visible_group

Whether the contact is visible in the UI; Yes (1), no (0)

Has_phone_number

The contact has at least one mobile phone number; Yes (1), no (0)

Lookup

An opaque value (which is a persisted store) that prompts you to find the value of a particular contact (if the value of its row ID is changed due to synchronization or aggregation)

status_update_id

single_is_restricted

Raw_contacts table

Contactscontract.rawcontacts

_id

The row ID. The synchronization adapter should try to maintain the row ID during the update process. In other words, it would be better to synchronize the adapter update with one raw_contact instead of deleting and re-inserting it.

is_restricted

Account_name

Indicates which account the contact was downloaded from in sync.

Account_type

Type of account

source_id

Unique indication of the type of this line account. Usually it is built when the raw contact is inserted and is never changed afterwards. A notable exception is a new raw contact: There will be an account name and type, but no source ID. This indicates that the sync adapter needs to create a new contact on the server side and store its ID in the corresponding source_id field on the phone.

Version

When a column or related data is modified, it is automatically modified

Dirty

The version changes the tag; (This line needs to synchronize the account it owns, and when the raw contact changes, it is automatically set to 1 (except for the URI has the Caller_is_syncadapter). The sync adapter should always provide query parameters to prevent unnecessary synchronization: the user changes some data on the server, the sync adapter updates the contacts on the phone (no caller_is_syncadapter flag) flag, when the dirty flag is set, thereby triggering synchronization, synchronizing changes to the server)

Delete

Delete tag; 0 or 1;1 indicates that it is marked as deleted.

contact_id

The _id in the Contacts table. By aggregating the process raw contacts is linked to the contact, which is controlled by the Aggregation_mode field and contactscontract.aggregationexceptions.

Aggregation_mode

Aggregation mode. The value is Aggregation_mode_default, aggregation_mode_disabled, or aggregation_mode_suspended.

aggregation_needed

0 or 1

Custom_rington

Ringtone associated with this record

Send_to_voicemail

Indicator to determine whether a call from this contact is sent to voicemail (1) or (0). When multiple raw_contacts aggregations are being aggregated, this field is automatically calculated: If all the aggregated raw_contacts are set send_to_voicemail=1, then this field is set to ' 1 '. Setting this field automatically changes the corresponding fields of all aggregated raw_contacts.

times_contacted

Number of contacts with this contact

last_time_contacted

Time of last contact

Statrred

is a common contact; Yes (1), no (0)

Display_name

Contact display name (it may be an e-mail address if the contact display name is not available)

Display_name_alt

An alternative representation of the display name of the contact, such as the Western name "first" instead of "last name in front".

Display_name_source

The type of data used as the display name of the contact, such as a structured name or e-mail address.

Phonetic_name

Phonetic_name_style

Soft_key

The key to sorting, consider the locale of the account, sort by the display name in the Address Book. Corresponds to Display_name (name split plus pinyin: "Ink", or "Mo Ink Ji").

Soft_key_alt

Sort key, based on the phonetic alphabet of the full name, corresponding to the Display_name_alt (name split plus pinyin: "Ink", or "Mo Ink Ji")

Name_verified

Contact_in_visible_group

Whether the contact is visible in the UI; Yes (1), no (0)

Sync1 to Sync4

Mimetypes table

_id

Row ID, corresponding to the mimetype_id in the data table

MimeType

As follows

_id mimetype

1 VND.ANDROID.CURSOR.ITEM/EMAIL_V2

2 Vnd.android.cursor.item/im

3 VND.ANDROID.CURSOR.ITEM/POSTAL-ADDRESS_V2

4 Vnd.android.cursor.item/photo

5 VND.ANDROID.CURSOR.ITEM/PHONE_V2

6 Vnd.android.cursor.item/name

7 vnd.android.cursor.item/organization

8 Vnd.android.cursor.item/nickname

9 vnd.android.cursor.item/group_membership

Ten Vnd.android.cursor.item/note

Vnd.android.cursor.item/website

Vnd.android.cursor.item/relation

Vnd.android.cursor.item/contact_event

1 is the mailbox, 2 chat account, 3 address, 4 picture; 5 phone number; 6 name; 7 company + position; 8 nickname; 9 belongs group; 10 remark; 11 URL

Calls table

Android.provider.CallLog.Calls

_id

Row ID,

Number

Call phone number

Data

The start time for dialing the phone number (as of 1970-01-01 00:00:00) calculated to the current difference in milliseconds

Duration

The duration of the call, in seconds

Type

Call type ("1" Call, "2" Dial Out, "3" not received)

New

The call has been confirmed or not. "1" means call, dial out, "0" for missed

Name

If the contact exists, the name of the contact associated with the phone number

Numbertype

Phone type associated with a phone number if the contact exists

Numberlabel

If the contact exists, the custom number type is associated with the phone number label (for example, voice) (Numbertype is 1-7 when Numberlabel is null; a custom label is displayed for 0 o'clock)

Typedial

Type of call (language phone, video phone)

Phone_lookup table

data_id

With data_id, you can find the relative data in a data table.

raw_contact_id

The relative data in the Raw_contact_ table can be found by raw_contact_id

Normalized_number

Sort each phone number in reverse order

Min_match

Groups table

Contactscontract.groups

_id

Row ID

package_id

Account_name

Account name

Account_type

Type of account

SourceID

Version

When a column or related data is modified, it is automatically modified

Dirty

Tags changed by version

Title

This group of displayed headings

Title_res

Notes

This group of comments

system_id

If it is a system group, the ID of this group, that is, a group that has a special meaning to the synchronization adapter, otherwise returns NULL.

Deleted

Delete tag; 0 or 1;1 indicates that it is marked as deleted.

Group_visible

Whether the group is visible in the UI; Yes (1), no (0)

Should_sync

Whether this group should be synchronized, yes (1), no (0)

Sync1 to Sync4

Accounts table

Android.accounts.Account

Account_name

Account name

Account_type

Account Type

Settings table

Android.provider.ContactsContract.Settings

Account_name

Account name

Account_type

Account Type

Ungrouped_versible

Flag whether the group is visible in the UI; "1" is visible, "0" is not visible

Should_sync

This flag controls the top-level synchronization behavior of this data source, based on the mode defined by the synchronization adapter.

Agg_exceptions table

Contactscontract.aggregationexceptions

_id

Type

Type of exception: Type_keep_together (1), Type_keep_separate (2), or type_automatic (3).

Raw_contact_id1

A reference to the _id of the "raw contact", the rule applies to.

Raw_contact_id1

A reference to the other _id of the "raw contact", the rule applies to.

RAW_CONTACT_ID1 and Raw_contact_id2 are referenced by a rule (type)

Sqlite_sequence table

Auto-numbered columns in SQLite

Name

The table where the AutoNumber field resides

Seq

The current number to use

Calls's SEQ 7 shows that we have 7 call logs.

In the development process, we often have to reset the table. In other words, all the records in the table are emptied and the auto-numbering is returned to 0. In SQLite, you only need to modify the Sqlite_sequence table:

updatesqlite_sequence SET seq = 0 WHERE name = ' TableName '

You can also delete the record directly:

Deletefrom sqlite_sequence WHERE name = ' TableName '

If you want to reset all the tables, simply empty the sqlite_sequence:

Deletefrom sqlite_sequence

_sync_state table

Contactscontract.syncstate

_id

Row ID

Account_name

Account name

Account_type

Account Type

Data

Android_metadata

Locale

Local language environment

Android Contact Database

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.