Whats is content provider?
Content provider is a mechanism to share data between application. Android doesn't provide common area to store data , so this is the only mechanism to share data between applications.Brief about how data sharing mechanism works using content provider?
- Content provider should expose its URI to the applications.
- Application will send URI to the ContentResolver
- ContentResolver will send this published query to ContentProvider
- ContentProvider will send back requested data to ContentResolver(CR), In responce CR send this data to application.
How to query a content provider?
Android provides below methods to make a query- ContentResolver.query()
- Activity.managedQuery()
What query methods return?
Cursor object.What are the steps to implment our own ContentProvider?
- Plan DB, URI's ,Column Names ,Column Type etc.
- Populate DB
- Extend ContentProvider abstract class
- Implenet methods query(), insert(), delete(), getType(), update()
- Register CP through android manifest file.