Obtaining contact information display and echo of Android mobile guard

The previous article has implemented the relevant layout, and this paper then implements the relevant functions

Read the system contact. After clicking the "select contact" button, the contact list will pop up. Reading the system contact is divided into the following steps:

The system contact provides a content provider to match the URL address through the content parser

1. Content parser

2. URL address, view the system contact database, content provider source code

First look at the list file of the API document, and then look at the Java class (there are multiple tables in the contact database)

contents://com.android.contacts/ Table name

3. Table structure of core table in system contact database

raw_ Contacts contact table: contact_ ID contact uniqueness ID value

Data user information table: raw_ contact_ ID as foreign key, and raw_ Contact in contacts_ ID for association query

Get the data1 field, which contains the phone number and contact name

mimetype_ The ID field contains the data type corresponding to the current row data1

Mimetypes type table: get the mimetypes in the data table_ ID and mimetypes_ ID to get the information type and phone number pointed to: vnd android. cursor. item/phone_ V2 user name: vnd android. cursor. item/name

4. Access method of table

content://com.android.contacts/raw_contacts content://com.android.contacts/data

The following is implemented in code

The results are as follows:

Contact information echo

Next, click the contact entry to realize echo. For example, double-click the first entry and the number will be added automatically

The code is as follows:

Next, add the following code to onactivityresult

After filling in the number, go to the next page and return again. It is found that the number is missing, so SP is used to store and read it

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>