Content providers - The name indicates all. It provides contents or data to applications. In Android, Content Providers are used to sharing data between the applications.
The android.content Package
The android.content package contains classes for accessing and publishing data. The Android framework enforces a robust and secure data sharing model. Applications are not allowed direct access to other application’s internal data. Two classes in the package help enforce this requirement: the ContentResolver and the ContentProvider.
Functions in a Content Provider |
How to ensure smooth database functionality?
- Make a Content Provider:- This will be a full Content Management System with methods to add, update, delete new data. It will establish a unique address (URI) for the databases in your application.
- Use a Content Resolver:- Given the address (URI) it will resolve the particular address and ask the associated database living there. (Content Provider). All methods acted on this address (URI) will be directed to methods defined in the respective Content Provider.
- Use a Cursor Loader Manager:- Any query performed inside the Content Provider will be done in the asynchronous thread by using loader manager.
- Use a Custom List adapter:- Query result will be adapted to a ListView using the Cursor pointing to rows of Database Tables.
Comments
Post a Comment