Android development —— 10, contentProvider realizes data sharing

URI
role:
used to uniquely identify the dataset

Features: All URIs provided to the provider are prefixed with "content://", and the "content://" mode indicates that the data is managed by the Content Provider.


A: A standard prefix used to identify that the data is managed by the content provider
B: Used to identify the Content Provider
C: Path to ContentProvider
D: The ID value of the particular record being requested.

To query the data in the Content Provider, the following three pieces of information are required:
Identification Change the URI of the Content Providerde
The data field name that needs to be queried The
type of data in the field
Customize the Content Provider
Developer defines a subclass of the ContentProvider class to use the ContentResolver and Cursor class bands It's convenient to share data. In principle, this means that the following 6 abstract methods defined by the ContentProvider class need to be implemented:

public boolean onCreate()
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder)
public Uri insert(Uri uri, ContentValues values)
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs)
public int delete(Uri uri, String selection, String[] selectionArgs)
public String getType(Uri uri)

The role of
Content Provider Content Provider is a bridge for data storage and retrieval between all applications. In Android, Content Provider is a special data storage type, which provides a set of standard methods to provide data addition, deletion, modification, and query functions.


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325718687&siteId=291194637