What is a ContentProvider and what is it typically used for?
Copied from https://developer.android.com/guide/topics/providers/content-provider-basics.html
Provide a way to share data with other apps. We can think ContentProvider as a wrapper of database adapter. When you want to access data in a ContentProvider, you have to use the ContentResolver object to communicate with the ContentProvider object.
The ContentProvider object receives data requests from clients, performs the requested action, and returns the results:insert, delete, update, query, call (call a provider-defined method. This can be used to implement interfaces that are cheaper and/or unnatural for a table-like model.)
public class MyContentProvider extends ContentProvider
Uri insert(Uri uri, ContentValues values);
int delete(Uri uri, String selection, String[] selectionArgs);
int update(Uri uri, ContentValues values, String selection, String[] selectionArgs);
Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder);
Bundle call(String method, String arg, Bundle extras);
3rd App 通过 ContentResolver 访问:
TASK_TABLE_URI = Uri.parse("content://"+AUTHORITY+"/"+TASK_TABLE_PATH);
mResolver.insert(TASK_TABLE_URI, values