Mobile Contact Storage Location
Like a text message, under Data-data.
Cell Phone Contact Database parsingExport the Contacts2.db table and view it through Sqliteexpert
mimetypes table: Stored data type (phone, avatar, name, email)
FOREIGN Key:
raw_contacts table: The ID of the person who holds the contact
contact_id: Contact person iddisplay_name: Contact name
data table: Information to store contacts
DATA1: Contact data data2: indata1 in the Mimetypes table is worth the valuemimetype_id: Contact person id,data data belongs toFOREIGN Key:raw_contact_id: Associating with raw_contacts tablesmimetype_id: Associating with Mimetypes tables
Contact Form
FOREIGN Key
get information about a contact person:
- Query the Raw_contact table and get the ID of the contact person.
- Query the data table based on the ID of the contact, and get the corresponding information from the contact.
- Querying the Mimetypes table for data types
Insert a contact information
- Insert the Raw_contact table first to write a new contact ID
- Writes to the data table based on the newly created ID data1 mimetype
Mobile Contact Source code AnalysisIn the contact Code of the Android system, Androidmenifest.xml defines an interface that provides an external query
in Android contact, you define the Urimatcher for the contact.
The Contactscontractdata in the Android API provides us with a response method and a simple use case:Add Method
Query Method
Remove Update method
StepsGet content ParserQuerying DataShow Data
Main code
Package Com.example.android_readphone.provider;import Android.content.contentresolver;import Android.database.cursor;import Android.net.uri;import Android.provider.contactscontract;import android.test.androidtestcase;/** * Test Get contact * * @author Zhaoyazhi * */public class Phoneprovidertest extends androidtestcase {public void readcontacts () {Contentresolver contentresolver = GetContext (). Getcontentresolver (); Cursor C = contentresolver.query (ContactsContract.RawContacts.CONTENT_URI, new string[] {"_id", "Display_name" }, NULL, NULL, NULL), while (C.movetonext ()) {String id = c.getstring (c.getcolumnindex (contactscontract.rawcontacts._id)) ; String name = c.getstring (C.getcolumnindex ("display_name")); SYSTEM.OUT.PRINTLN ("Ordinal ID:" + ID + "----------name:" + name);} C.close ();}}
Output Result:
Android Contact System Source: http://download.csdn.net/detail/zhaoyazhi2129/7491109