I'm new to Android and have successfully implemented an ArrayAdapter
to display a list of simple objects in a ListView
. I have also created a class that extends SQLiteOpenHelper
and I'd like to use this to display a list of rows from the database in the ListView
.
From what I can tell, it seems like I should be using a Loader
to asynchronously query the data, and act as a middle man between my data and the UI.
The Loader
and CursorLoader
documentation only refers to how to achieve this when querying a ContentProvider
. This led me to think that the best approach may be to create a ContentProvider
which provides a structured interface to my database - but the Android documentation on creating a ContentProvider
states:
You don't need a provider to use an SQLite database if the use is entirely within your own application.
Are there any particular reasons why I shouldn't write a ContentProvider
? Unless I'm missing something it seems like this would provide a good abstraction for the data layer and mean I can have all the benefits of using a CursorLoader
when consuming it.
In my case the database is only for use by my application - so what alternatives are there and are there any good tutorials which show the process start to finish?
Thanks!