The content provider Manages access to the core resource library of data. The provisioner is an android application.ProgramIt often provides its own UI to work with data. However, the main purpose of the content provider is to provide other applications, which use the client object of the provider to access the provider. The provider and the provider client provide a consistent and standard interface for data processing and secure data access between processes.
This topic mainly introduces the following basic content:
1. How the content provider works;
2. Use APIs to obtain data from the content provider;
3. Use APIs to insert, update, and delete data in the content provider;
4. Other API functions that work with the provider.
Overview
The content provider uses one or more tables similar to relational database tables to present data to external applications. A row represents an instance of certain data types collected by the provider, and each column in each row represents a separate data collection segment of an instance.
For example, the user dictionary is one of the built-in providers in the Android platform. It stores the spelling of non-standard words that the user wants to keep. Table 1 describes the data that may exist in the table of the provider.
Table 1. user dictionary example
Word |
APP ID |
Frequency |
Locale |
_ Id |
Mapreduce |
User1 |
100 |
En_us |
1 |
Precompiler |
User14 |
200 |
Fr_fr |
2 |
Applet |
User2 |
225 |
Fr_ca |
3 |
Const |
User1 |
255 |
Pt_br |
4 |
Int |
User5 |
100 |
En_uk |
5 |
In table 1, each row represents an instance of words that cannot be found in the Standard Dictionary. Each column represents some data of that word, such as the locale column. The column header is the name of the column stored in the provider. To reference the locale value of a row, it must point to the locale column of this row. For this provider, the _ ID column is the "primary key" column automatically maintained by the provider.
Note: the provider does not have to have a primary key. If a primary key exists, you do not need to use _ id as the column name. However, if you want to bind data from the provider to a listview, you must have a column named _ id. This requirement will be explained in more detail in the "display query results" section.