Thursday, 22 August 2013

Android ContentProvider/Loader vs. Loading to Objects

Android ContentProvider/Loader vs. Loading to Objects

I have an Android application with an SQLite DB with several tables that
reflect several types of objects. I am now and have in the past loaded the
SQLite data to ArrayLists before presenting the data to the user in list
views. Pretty much load all the required data into objects, hold them in
the memory and check to make sure no duplicates are added. I share the
objects in an Application object so I can access them across separate
activities.
I'm wondering if using a loader and creating a content provider for the
list is a better approach. I think it would make the code simpler in the
long run. The advantage of a loader is that it is on the fly and on
another thread right? I'm not too concerned with speed because I have only
a few rows to load, but it may be easier for a loader and content provider
than managing the DB and temporary ArrayLists as I have to do now.
Anyone have have any suggestions? Again, speed is not a huge problem, but
would using loaders be recommended and simpler? Thanks.

No comments:

Post a Comment