Leon
Leon

Reputation: 12481

ORMLite performance: ArrayAdapter vs CursorAdapter vs a custom adapter

I have relatively small H2 database. I am expecting no more than 100 entries and even that feel highly over the top.

I have a list view with some controls and use an ArrayAdapter with a call to QueryAll() to populate the data. It works perfectly as I can modify the data in the array in memory when a button is pressed and then write the result to DB without having to reload it. But the initial load is surprisingly slow

What I wonder is whether I should rather use a CursorAdapter, since it seems more fitting to the problem or write a custom adapter to make use of the DAO Iterator.

Will there be a performance improvement using Cursor or a custom adapter? In my mind it feels like a custom adapter should give the best performance.

Upvotes: 3

Views: 2077

Answers (2)

jaumard
jaumard

Reputation: 8292

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 in the ListView is between 5 and 10. So I think if you use a CursorAdapter you will not have loading problems.

Regards

Upvotes: 5

amalBit
amalBit

Reputation: 12181

Its better to use a custom adapter with Content provider.

Upvotes: 2

Related Questions