Question

I am developing an app for Android Api 15 and above.

I have been using a custom CursorAdapter implementation with a ListView for some time now. I was under the impression that even with many thousands of rows (records) the ListView would handle the performance side of things.

My phone, a Sony Xperia U, has a hard time scrolling beyond 10 - 20 rows. The first few rows scroll nicely and then I hit a wall of stuttering and the device becoming unresponsive (A total of 70 rows all together). It is running Android 4.0.4. Other phones such as the Samsung S3 and Sony Xperia Z perform much better, but at what point is this going to degrade. These 2 phones are running 4.1. I am getting the CursorWindow warning seen below on the Xperia U.

I have implemented all the tricks in the trade, ViewHolder pattern etc, and all images are loaded inside AsyncTask's.

Anyway, the trouble I am having regarding performance does not lie inside the BindView. The BindView method completes quite quickly - within 1-3 milliseconds.

The problem I believe lies with the CursorWindow. I really don't even know what this is!

08-14 21:01:58.913: W/CursorWindow(7116): Window is full: requested allocation 277981 bytes, free space 148792 bytes, window size 2097152 bytes

I also read there is an issue in CursorWindow up to potentially 4.2 but this could be false:

http://code.google.com/p/android/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars&groupby=&sort=&id=4993

When it comes to the data for each row, I have an SQLite blob:

byte[] avatar = cursor.getBlob(cursor.getColumnIndex(Profile.TABLE_COLUMN_AVATAR));

I think this might be one of the issues, but I am uncertain. I probably should switch the image/s to an SD card and store the path in the DB instead. I would like to keep my current setup though.

This then suggests that my current approach is not going to be manageable and hence a new approach might be necessary. So this gets me thinking about an Endless Adapter solution which would mean getting the cursor data with a limit/offset and filling up an ArrayAdapter and using a framework like CommonWare's EndlessAdapter (perhaps)?

  1. Does my performance problem lie less with the CursorAdapter and more with the use of Blobs?
  2. Should I be using an Endless Adapter approach with potentially large data sets?
  3. Is CommonWare's EndlessAdapter still a good solution after 4 years?
Was it helpful?

Solution

Does my performance problem lie less with the CursorAdapter and more with the use of Blobs?

Use Traceview to determine exactly where your problem lies. In the future, you might also consider being a lot more specific in your question, as we have no idea what a "hard time" means.

Should I be using an Endless Adapter approach with potentially large data sets?

If your "hard time" is in initially loading the data out of your database, perhaps, though somebody out there may have an endless-list solution that will work OK with a set of CursorAdapters.

If your "hard time" is in scrolling the results, then no, EndlessAdapter or equivalents will not help you.

Is CommonWare's EndlessAdapter still a good solution after 4 years?

For its use case, sure. Then again, I'm biased. :-)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top