Android provides the "Contact" application, which is easy to use. It includes some common data type fields, such: contact name, phone number, Im address, email address, and so on. However, Android does not store the contact information as we think: open a table directly, and each row corresponds to a contact. One row contains all the data domain types, if this data type is not available, it will be empty.
In fact, it is not as simple as we think. to query or store contact information, when designing a pre-defined contact database table in Android, compatibility with future versions or feature extensions, as well as the efficiency and security and stability of the query, read, and modification processes must be considered. After careful study, it is found that the pre-defined database storage of the contact system is still complicated.
In android1.x, all the APIS provided are in Android. provider. contacts, but after Android, it was originally in Android. provider. all the APIS under contacts are depreciate. Instead, the query efficiency and data storage APIs are more standardized: COM. provider. contactscontract.
In the SDK documentation, there is such a sentence to describe contactscontract:
The contract between the contacts provider and applications. that is to say, it provides some interface protocols and regulations between the application and contacts provider, so that the app is more convenient when calling the data related to contacts provider. (PS: Actually, my feeling is that the SDK is too heavy and there are too many APIs. Every time I use it, I need to find the corresponding tutorial on the foreign language network to learn, next I will provide a tutorial link)
Contactscontract defines an extensible database of contact-related information. Contact information is stored in a three-tier Data Model:
Contactscontract defines an extensible database for information related to contacts. The contact information is stored in the layer-3 Data Model:
1,ContactsContract.Data
2,ContactsContract.RawContacts
3,ContactsContract.Contacts
For the introduction of these important classes, you can refer to the SDK. It is complicated and you will understand it later.
Well, after learning about the functions of these classes and the corresponding API interfaces, you may still be confused and still do not know how to use them, in this case, you can refer to a tutorial I found in the example to explain how to use Com. provider. the methods in the contactscontract package are used to read, write, and modify the "Contact" database.
I think you can save important and valuable webpages locally, in case the webpage is deleted and cannot be accessed.
Web: http://www.higherpass.com/Android/Tutorials/Working-With-Android-Contacts/1/
There are a total of five pages of tutorials. I have read more about the nature of contactscontract. In addition, we can also see from the source code provided by it the rationality of its architecture design.
In fact, some SQLite operations are included, and the following section also describes Android tutorial, which is good:
http://www.higherpass.com/Android/Tutorials/Accessing-Data-With-Android-Cursors/