Common URIs for Android systems

Source: Internet
Author: User

Common URIs for Android systems

The URI of the Android system management contact is as follows:
ContactsContract.Contacts.CONTENT_URI managing a contact's URI
ContactsContract.CommonDataKinds.Phone.CONTENT_URI the URI of the phone that manages the contact
ContactsContract.CommonDataKinds.Email.CONTENT_URI the URI of the email that manages the contact

(Note: Contacts has two tables, respectively, Rawcontact and Data,rawcontact record the user's ID and name,

Where the ID column name is: contactscontract.contacts._id, the Name column is ContactContract.Contracts.DISPLAY_NAME, The foreign key ID of the telephone information table is ContactsContract.CommonDataKinds.Phone.CONTACT_ID, The phone number column name is: ContactsContract.CommonDataKinds.Phone.NUMBER.

Reference: http://blog.sina.com.cn/s/blog_90cdca4c01010zm4.html


The name of the email address bar in the data table is:
ContactsContract.CommonDataKinds.Email.DATA
The key bar is: ContactsContract.CommonDataKinds.Email.CONTACT_ID)


The ContentProvider URI provided by Android for multimedia is as follows:
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI audio files stored on an SD card
MediaStore.Audio.Media.INTERNAL_CONTENT_URI audio files stored on the phone's internal memory
MediaStore.Audio.Video.INTERNAL_CONTENT_URI video on your phone's internal memory


Image file contents on SD card
MediaStore.Images.Media.INTERNAL_CONTENT_URI image on the internal memory of the phone
MediaStore.Images.Media.EXTERNAL_CONTENT_URI Video on SD card

(Note: The picture's display name bar: Media.display_name, the picture's detailed description column is: media.description

Where to save the picture: Media.data


SMS Uri:content://sms

SMS Uri:content://sms/outbox in the Sending box

(corresponding column name address, subject (title), time)

Query contacts in Contacts?
Cursor CR =getcontentresolver (). query (ContactsContract.Contacts.CONTENT_URI, NULL, null,null, NULL);

What if we just want to get the phone number?
Cursor phone = cr.query (Contactscontract.commondatakinds.phone.content_uri,null, ContactsContract.CommonDataKinds.Phone.CONTACT_ID + "=" +contactid, null, NULL);

Replace the above statement with the following:
Cursor phone = cr.query (Contactscontract.commondatakinds.phone.content_uri,null, ContactsContract.CommonDataKinds.Phone.CONTACT_ID + "=" +contactid + "+" + Contactscontract.commondatakinds.phone.type+ "=" + ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE, null,null);
ContactsContract.CommonDataKinds.Phone.TYPE represents the type of contact phone, which corresponds to the following:
Type_mobile: Mobile phone number
Type_home: Residential Phone
Type_work: Company Phone

Finally remember to read the contact's API in the Androidmanifest.xml statement:
<uses-permissionandroid:name= "Android.permission.READ_CONTACTS"/>

Common URIs for Android systems

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.