Android content provisioner-content provisioner BASICS (unified content resource identifier (URIs ))

Source: Internet
Author: User

The content URI identifies the unified resource ID of data in the provider. The unified resource ID of the content includes the complete provider's symbolic name and a table name. When you call a client method to access a table in the provider, the Uniform Resource ID of the table content should be one of the parameters.

PreviousCodeThe constant content_uri contains the unified resource ID of the words table in the user dictionary. The contentresolver Object Analyzes the URI authorization and compares the authorization with the authorization of a known system table to find the content provider, then the contentresolver object can distribute the query parameters to the correct provider.

The contentprovider object is the path part of the uniform content resource identification to select the table to be accessed. The provisioner usually exposes a path for each table.

In the previous code line, the complete URI of the "Words" table is:

Content: // user_dictionary/words

The user_dictionary string is the provider's authorized location, and the words string is the table path. String content: // (solution) is always fixed. The identifier is a unified resource identifier of the content.

Many providers allow you to add an id value at the end of the URI to access a single row in the table. For example, to obtain the row of data whose _ id is 4 from the user dictionary, you can use the following URI:

Uri singleuri = contenturi. withappendedid (userdictionary. Words. content_uri, 4 );

The id value is often used to obtain the row set to be updated or deleted.

Note:The URI and Uri. Builder classes provide convenient methods for constructing a URI with a good format using strings. The contenturis class provides a convenient method to add an id value to the URI. In the previous code snippet, The withappendedid () method is used to add an id value to the content URI of the user dictionary.

Related Article

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.