The Database Design of Android 2.x and 1.x contacts is very different. When developing contacts, you must first determine the system version.
Boolean mandroid2 = Android. OS. Build. version. Release. startswith ("2 .");
This article describes some of the development processes and applies to Versions later than 2.x.
Overall.
The main data of a contact is stored in raw_contacts and data tables, which form a master-slave table relationship.
Raw_contacts table structure:
Data Table Structure:
Each contact has a record in raw_contacts, such as the address, name, email, and phone number. data is stored in data, which is easy to expand, for example, to add a contact's email address, you only need to add a record in data.
The contact database is complex. In the development of contact-related applications, it is generally not directly operated by database fields. It is mainly operated by views (specified URIs.
The following describes the data of some contacts I have used in development.
Name:
Uri: URI. parse ("content: // com. Android. Contacts/Data ")
Prefix = "data4"; // name prefix
Mid_name = "data5"; // intermediate name
Given_name = "data2"; // name
Family_name = "data3"; // last name
Mid_pinyin = "data8"; // pinyin
String family_name_pinyin = "data9"; // pinyin
String sufix = "data6"; // name suffix
String sufix_pinyin = "data7"; // name: pinyin
Tel:
Uri: URI. parse ("content: // com. Android. Contacts/data/phones"
Phone: "data1"; // number
Type: "data2"; // This field is an integer that indicates the phone type.
The Type ing is as follows:
Type_custom = 0;
Type_home = 1;
Type_mobile = 2;
Type_work = 3;
Type_fax_work = 4;
Type_fax_home = 5;
Type_pager = 6;
Type_other = 7;
Email:
Uri: URI. parse ("content: // com. Android. Contacts/data/emails ")
Email: "data1"; // email address
Type: "data2"; // This field is an integer that indicates the email type.
The Type ing is as follows:
Type_custom = 0;
Type_home = 1;
Type_work = 2;
Type_other = 3;
Type_mobile = 4;
Address:
Uri: URI. parse ("content: // com. Android. Contacts/data/postals ")
Street = "data4"; // Street
City = "data8"; // City
State = "data7"; // state
Zip_code = "data9"; // zip code
Type: "data2"; // type:
Type_custom = 0;
Type_home = 1;
Type_work = 2;
Type_other = 3;