Search This Blog

Monday 18 June 2012

Basics About Content Providers



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.
Example of user dictionary table
wordapp idfrequencylocale_ID
mapreduceuser1100en_US1
precompileruser14200fr_FR2
appletuser2225fr_CA3
constuser1255pt_BR4
intuser5100en_UK5
 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