Wednesday, 19 November 2014

How to create Content Provider and its Steps in Android ?

Content Provider is a component which

1)- hides database details ( database name , table name , coloumn info. etc.).
2)- allows application to share data among multiple application.

Steps to create Content Provider :

i)- Create C.P subclass (android.ContentProvider).
ii)- Register C.P in AndroidManifest.xml using Provider element(<Provider>).

To register Content Provider use following attributes :

1- android:name -> C.P subclass name.
2- android:authorities -> authority used for C.P
3- android:exported - >true/false.

true:-> C.P can be used in other applications.
false:-> C.P can be used in local applications ( the application which is defining C.P).

by default it is true.


i)- Stands for Universal Resource Identifier.
ii)- It is used to identify C.P uniquely in currentr device.
iii)- URI has a special format. i.e.

Content : // Authority / Path / Record Id

No comments:

Post a Comment