Content Providers
A Content Provider is Android’s standardized data-sharing layer.
It is a contract + IPC mechanism that lets one app expose data to other apps in a controlled, permission-aware way.
Why Content Providers
Apps are sandboxed.
One app cannot directly read another app’s:
SQLite database
files
in-memory data
Core Idea
A Content Provider exposes data via URIs, and clients interact using CRUD operations, not implementation details.
1. Authority
A unique identifier for the provider.
2. URI structure
Examples:
This URI is the API surface of your data.
3. CRUD methods
Every Content Provider implements these:
These are process-safe and run via Binder IPC.
Clients use ContentResolver, not the provider directly.
4. ContentResolver (client side)
Apps never talk to providers directly.
Cursor
Query results come back as a Cursor.
Cursor is:
Lazy
Memory-efficient
IPC-friendly
You move row by row instead of loading everything at once.
Permissions and security
Manifest-level permissions
You can:
Allow read only
Allow write only
Restrict access per operation
System Content Providers
ContactsProvider
MediaStore
CalendarProvider
SettingsProvider