Android content providers'-content providers' BASICS (access providers)

Source: Internet
Author: User

The application uses the contentresolver client object to access data from the client. This object has the same naming methods as those in the provider. The provider is an instance of a specific subclass of contentprovider. The contentresolver object method provides the basic "crud" (create, obtain, update, and delete) Persistence saving function.

The contentresolver object in the Process of the client application and the contentprovider object in the provider's own application automatically process inter-process communication. The contentprovider object also plays the abstract layer role between the data resource library and the external performance of the data in the form of tables.

Note:To access a provisioner, you usually need to request a special license in the list file. For a more detailed description, see "content providers license"

For example, to obtain the list of words and positions from the user dictionary provider, you must call the contentresolver. Query () method. The query () method calls the contentprovider. Query () method defined by the user dictionary provider. The following code calls the contentresolver. Query () method:

// Queries the user dictionary and returns results
Mcursor = getcontentresolver (). Query (
Userdictionary. Words. content_uri, // The content URI of the words table
Mprojection, // The columns to return for each row
Mselectionclause // selection criteria
Mselectionargs, // selection criteria
Msortorder); // The sort order for the returned rows

Table 2 shows how the parameters of the query (Uri, projection, selection, selectionargs, sortorder) method match the SQL SELECT statement:

Table 2: Comparison between the query () method and SQL query.

Query () method parameters

Select keywords/parameters

Description

Uri

From table_name

Uri maps to the table named in the provider.

Projection

Col ,...

Array of columns to be selected in each row.

Selection

Where Col = Value

Specify Selection Conditions

Selectionargs

Used to replace "?" In the selectiong Parameter .

 

Sortorder

Order by col, Col ,...

Sort criteria of specified rows

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.