[Android] mobile guards read contacts

Get the contentresolver content parser object through the getcontentresolver () method

Call the query () method of the contentresolver object to get raw_ Get the cursor object from the data in the contacts table

Parameters: URI object, field string array

Get URI object through uri.parse(“ content://com.android.contacts/raw_contacts ”)Method,

While loops the cursor object if the movetonext() method of the cursor object is true

Call the getString () method of cursor object, and the parameter is index

If it is judged not to be null, query another table

Call the query () method of the contentresolver object to get the data in the data table and the cursor object

Parameters: URI object, field string [] array (data1, mimeType), condition string, condition value string [] array (contact_id)

The URI object is uri.parse(“ content://com.android.contacts/data ”)

The loop is the same as above

The corresponding type of name is vnd.android.cursor.item/name

The corresponding type of phone is vnd.android.cursor.item/phone_ v2

Permission required, android.permission.read_ CONTACTS

Call the setadapter () method of the listview object to allocate data to the view. The parameter is the adapter object

Get the adapter object through new simpleadapter()

Parameters: context, data collection, layout resource, field string [] array, control int [] ID array

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
分享
二维码
< <上一篇
下一篇>>