Question

In my app I want to show a list of apps that I have placed in an resource file. I parse the XML(resource) file and then save the value in a SQLiteDatabase. I have implemented my Database inside a ContentProvider. What I want to know is do I need a Custom CursorLoader (should I extend CursorLoader?)? or will CursorLoader itself will be sufficient. I have seen an example, but in this no ContentProvider has been used.

Can someone explain when should I implement a Custom CursorLoader as against using the original one?
(A little unrelated) Also what would be the best practice, to implement a database with or without a ContentProvider?

Thanks in Advance!

Was it helpful?

Solution

There are many ways to implement it -

  1. If using a ContentProvider there is no need to extend the CursorLoader.
  2. If not using a ContentProvider and using a SQLiteDatabase instead, we can extend the CursorLoader with our Custom-Loader and override the loadInBackground() method of CursorLoader and instead of querying the ContentProvider we can query the SQLiteDatabase.
  3. While using a SQLiteDatabase we can extend AsyncTaskLoader, however, this is more
    tedious method than one specified in 2.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top