Hy,
I have been reading about content providers, Loaders and loaderManagers for whole week now and sadly I must admit, I'm no closer to working solution. And also, I think integrating full blown loadermanager-cursorLoader system would be perhaps an overkill for my needs. So if any of you could assess if this is true (or just excuse from my side :)), maybe direct me in right direction or even provide working example/implementation steps for my specific case, that would be great!
Background:
So my questions are:
Thank you all!
Loaders are used to move potentially long-running database queries into another thread (and to keep the data when the activity is recreated, e.g. on screen rotations).
When your query is fast, you can just run it directly from the UI thread.
Android's built-in CursorLoader
requires a content provider, but you can write your own loader that accesses the database directly: Usage CursorLoader without ContentProvider.
Cursor adapters require that query has a column named _id
containing unique values.
You could rename some other unique column to _id
while querying (SELECT SomethingElse AS _id ...
), but when you have a primary key, you could just as well store it as _id
in the database.
(SQLite ignores case in column names.)