vendredi 26 février 2016

Android: efficiency of CursorLoader-swapCursor vs ArrayList-notifyDataSetChanged?

I have a list which usually contains < 100 entries. Sometimes 200-1000 entries. Occasionally it can contain many more such as 20000 entries. Data is queried from a few SQLiteDatabase tables.

  1. I load and display the data in a ListView.
  2. I do various reads/writes in other app logic such as in a service etc.
  3. I do operations such as: move some items around, to beginning or end of the list, modify their content, delete them, add new ones etc. - and save changes in the DB.

    • For the ListView I call mAdapter.notifyDataSetChanged().

    • I consider implementing a Loader (SQLite query loader) to use Loaders. The loader will observe data changes, re-run the query and I would use mAdaptor.swapCursor() to use the new Cursor.

My question is: while both methods would be asynchronous, which one of the above would be more efficient? (shorter loading time etc)?

Aucun commentaire:

Enregistrer un commentaire