Better to use Cursor adapter or Array adapter

android, android-sqlite, database, listview

Solution

In your case `CursorAdapter` is more appropriate when there is a database because it does not load all the records as `ArrayAdapter`. It loads only the visible records, or the records you are querying. Here is the documentation for CursorAdapter:

Adapter that exposes data from a Cursor to a ListView widget.

The Cursor must include a column named "_id" or this class will not work. Additionally, using MergeCursor with this class will not work if the merged Cursors have overlapping values in their "_id" columns.

As from the doc of Content provider so it might not useful for you.

You don't need a provider to use an SQLite database if the use is entirely within your own application.

You can choose `CursorAdapter` over `ArrayAdapter`.

Problem

i have around 100's of schedules stored in database which needs to display them based on Listview based on requirements like, weekly basis, next week, next month, over due schedules etc... Is it good to load all the schedules on launch of application and show them based on the option user chooses (Weekly, overdue, monthly etc...) in array adapter. Or at run time use the query, fetch the results from DB and use the cusor to load the data on listview using cusoradapter?. Which method is effeciant?, i feel querying the DB always is expesive operation? is it really true?.

Original source

Related problems