View on GitHub

Bearded-android-docs

ContentProvider

Download this project as a .zip file Download this project as a tar.gz file

Created Sunday 14 July 2013

A content provider manages a shared set of application data. You can store the data in the file system, an SQLite database, on the web, or any other persistent storage location your application can access. Through the content provider, other applications can query or even modify the data (if the content provider allows it). For example, the Android system provides a content provider that manages the user's contact information. As such, any application with the proper permissions can query part of the content provider (such as ContactsContract.Data) to read and write information about a particular person.

When you want to access data in a content provider, you use the ContentResolver object in your application's Context to communicate with the provider as a client.

To retrieve data from a provider, your application needs "read access permission" for the provider. You can't request this permission at run-time; instead, you have to specify that you need this permission in your manifest, using the <uses-permission> element and the exact permission name defined by the provider.

The next step in retrieving data a provider is to construct a query.

Note: A provider isn't required to have a primary key, and it isn't required to use _ID as the column name of a primary key if one is present. However, if you want to bind data from a provider to a ListView, one of the column names has to be _ID. This requirement is explained in more detail in the section Displaying query results.

!Links


No backlinks to this page.
comments powered by Disqus