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.