Configuration: Uri

Source: Internet
Author: User

A URI is a definition of a network resource that represents the data to be manipulated, and theURI mainly contains two pieces of information: 1" ContentProvider to operate 2" what data in the ContentProvider is manipulated  a URI consists of the following parts: L[1] standard prefix, used to describe a content provider control of these data, can not be changedContentProvider(content provider) scheme has been provided by Android, scheme :content://  [2] The identifier of the URI, which defines which content provider provides the data for third-party applications, to guarantee the uniqueness of the URI identity, it must be a complete, lowercase class name. The hostname (or authority) is used to uniquely identify the contentprovideR, and the external caller can find it based on this identity.  Note: In order for other apps to find the contentprovider,ContentProvider uses the authorities(hostname /domain) to uniquely identify it, and you can ContentProvider as a website (think, the site is also to provide data),authorities is his domain name.  [3] pathcan be used to represent the data we want to manipulate, the path should be built according to the business Content provider uses these paths to determine what type of data is currently required, which may not include a path, or may include multipleas follows : to manipulate records with ID 10 in the person table , you can build such a path :/PERSON/10 to manipulate the Name field of a record with an ID of ten in the person table , Person/10/name to manipulate all the records in the person table , you can build such a path :/person to manipulate records in the xxx table , you can build such a path :/xxx  [4] If the URI contains, indicating the ID of the record that needs to be obtained, if there is no ID, it returns allOf course, the data to be manipulated does not necessarily come from a database, or it can be a file and other storage methods, as follows : to manipulate the name node under the person node in the XML file , you can build such a path:/person/name  If you want to convert a string to a URI, you can use the Parse () method in the Uri class, as follows: uri uri = uri.parse ("Content://cn.itcast.provider.personprovider/person") because URIs are usually long and sometimes error-prone, they are difficult to understand. So, there are some helper classes defined in Android, and some constants are defined to replace these long strings, for example: People.content_uri

Configuration: Uri

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.