2. ContentProvider
Manages data
Can use almost any storage option
SQLite
File
API
…
Provides consistent interface (CRUD)
Can be restricted with permissions
extends ContentProvider class
5. CRUD
Method Usage
insert Inserts one object. The URI must be directory-based
query Queries for all objects that fit the URI.
update Updates one or all object(s)
delete Deletes the object(s) for the URI provided.
6. Insert (Create)
Type Name Usage
URI uri The URI of the object(s) to access.
ContentValues values The values for the object to add.
7. Query (Read)
Type Name Usage
URI uri The URI of the object(s) to access.
String[] projection This String array indicates which
columns/attributes of the objects you
want to access
String selection With this argument you can determine
which records to return
String[] selectionArgs The binding parameters to the
previous selection argument
String sortOrder If the result should be ordered you
must use this argument to determine
the sort order
9. Update(Update)
Type Name Usage
URI uri The URI of the object(s) to
access.
ContentValues values The values for the object to
add.
String selection With this argument you can
determine which records to
affect
String[] selectionArgs The binding parameters to the
previous selection argument
10. Delete(Delete)
Type Name Usage
URI uri The URI of the object(s) to
access.
String selection With this argument you can
determine which records to
affect
String[] selectionArgs The binding parameters to the
previous selection argument
12. URI
content://authority/path/id
authority: is Java namespace of the
content provider implementation. (fully
qualified Java package name)
path: is the virtual directory within the
provider that identifies the kind of data
being requested.
id: is optional part that specifies the primary
key of a record being requested. We can
omit this part to request all records.
13. URI (sample)
authority: our authority is…
com.example.rememberme.provider.PersonContentProvider
path: using table name
person
15. MIME Types
Used to determine supported object
types
Prefixed with:
vnd.android.cursor.item
Single item
vnd.android.cursor.dir
List of items