What is content provider? Why we use it over our internal storage?
- 11 months ago
If you are not planning to share data, don't think about Content Providers. They are powerful but hard to write and it will be just silly to implement them if you are going to use them internally.
Of course... for instance, for an old TODO list app I wrote, I had to write a content provider to allow other apps retrieve and access the tasks states. It was part of the requirements, but more than that it made sense and made the app nicer.
once the Content Provider is implemented you gain a lot of benefits. For example, you can use the
CursorLoader to perform asynchronous queries... you have access to a singleton instance (the
ContentResolver) to perform queries, etc. Of course you could implement your own Loader to use for your SQLite database... of course you could implement access to a single database instance across the entire application... and of course, a ContentProvider isn't required unless you wish to share