Note that there are some explanatory texts on larger screens.

plurals
  1. POMoving from CursorAdapter to an Endless adapter implementation
    primarykey
    data
    text
    <p>I am developing an app for Android Api 15 and above.</p> <p>I have been using a custom <code>CursorAdapter</code> implementation with a <code>ListView</code> for some time now. I was under the impression that even with many thousands of rows (records) the <code>ListView</code> would handle the performance side of things. </p> <p>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 <code>CursorWindow</code> warning seen below on the Xperia U.</p> <p>I have implemented all the tricks in the trade, <code>ViewHolder</code> pattern etc, and all images are loaded inside <code>AsyncTask</code>'s.</p> <p>Anyway, the trouble I am having regarding performance does not lie inside the <code>BindView</code>. The <code>BindView</code> method completes quite quickly - within 1-3 milliseconds.</p> <p>The problem I believe lies with the <code>CursorWindow</code>. I really don't even know what this is!</p> <pre><code>08-14 21:01:58.913: W/CursorWindow(7116): Window is full: requested allocation 277981 bytes, free space 148792 bytes, window size 2097152 bytes </code></pre> <p>I also read there is an issue in <code>CursorWindow</code> up to potentially 4.2 but this could be false:</p> <blockquote> <p><a href="http://code.google.com/p/android/issues/detail?can=2&amp;start=0&amp;num=100&amp;q=&amp;colspec=ID%20Type%20Status%20Owner%20Summary%20Stars&amp;groupby=&amp;sort=&amp;id=4993" rel="nofollow">http://code.google.com/p/android/issues/detail?can=2&amp;start=0&amp;num=100&amp;q=&amp;colspec=ID%20Type%20Status%20Owner%20Summary%20Stars&amp;groupby=&amp;sort=&amp;id=4993</a></p> </blockquote> <p>When it comes to the data for each row, I have an <code>SQLite</code> <code>blob</code>:</p> <pre><code>byte[] avatar = cursor.getBlob(cursor.getColumnIndex(Profile.TABLE_COLUMN_AVATAR)); </code></pre> <p>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.</p> <p>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 <code>ArrayAdapter</code> and using a framework like CommonWare's <code>EndlessAdapter</code> (perhaps)?</p> <ol> <li>Does my performance problem lie less with the <code>CursorAdapter</code> and more with the use of <code>Blob</code>s?</li> <li>Should I be using an Endless Adapter approach with potentially large data sets?</li> <li>Is CommonWare's <code>EndlessAdapter</code> still a good solution after 4 years?</li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload