Basic about content providers
Content Providers in android is used to manage and share data between applications in secure manner. Content Providers manage access to the structured set of data. The data is encapsulated and shared a standard interface that connects data in one process with code running in another process.
The application access the data is known as consumer application and the application providing the data is known as provider application.
The consumer application connects to provider application as client using ContentResolver object. The ContentResolver communicates with the provider object, an instance of a class that implements ContentProvider.
The Provider object receive data from the client and perform actions on that data and send a result to the Resolver Object of consumer application.
If you want to share your data to other applications then only you need to implement a content provider.
Android provide various content providers in a package android.provider.
The various type of audio, video and contact data is shared with content providers in android
Content Providers : Content Provider is used to publish data from the application.Content Provider represents the data in a form of a table just like a table in relational databases. The row defines a set of data (instance of data provider collects from applications) and column defines the individual piece of the data.
For example, one of the built-in providers in the Android platform is the user dictionary, which stores the spellings of non-standard words that the user wants to keep.
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 |
For this provider, the
_ID
column will be treated as a "primary key" column which is automatically manage by the provider.
Content Resolver : Content Resolver is used to access data from the application. Content Resolver provides the methods to create, retrieve, update and delete (CRUD).
The content provider and content resolver performs a secure inter-process communication to share and access the data among different applications.
No comments:
Post a Comment