3.APP components-content Providers

Source: Internet
Author: User

1. Content Providers

A content provider manages access to a central repository of data.

A provider is part of a Android application, which often provides it own UI for working with the data. However, content providers is primarily

    intended to is used by other applications, which access the provider using a Provider client object. Together, providers and provider clients

offer a consistent, standard interface to data, also handles inter-process communication and secure data access.

2. Overview

  2.1 Accessing a provider

An application accesses the data from a content provider with a ContentResolver client object. This object has methods the call

Identically-named methods in the provider object, an instance of one of the concrete subclasses ContentProvider of. The

      ContentResolverMethods provide the basic "CRUD" (Create, retrieve, update, and delete) functions of persistent storage.

  2.2 Content URIs

A content URI is a URI, which identifies data in a provider. Content URIs include the symbolic name of the entire provider (its authority)

and a name, points to a table (a path). When you call a client method to access a table in a provider, the content URI for the

Table is one of the arguments.

3. Retrieving Data from the Provider

To retrieve data from a provider, follow these basic steps:

<1> Request The Read access permission for the provider.

<2> Define The code that sends a query to the provider

3.1 Requesting Read Access Permission

To retrieve data from a provider, your application needs "Read access permission" for the provider

3.2 Constructing the query

    

3.3 Displaying Qurey Results

3.4 Getting data from Qurey results

3.APP components-content Providers

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.