Hello Mark,

Thanks for the quick response (again)!

I hope you are over the head cold by now :D

Thoroughly enjoying the books by the way - they far exceed the level
of detail of the others in my collection.
I'm only disappointed that I didn't discover them weeks ago :)

The 50000 records is of course an exaggeration, I just want to achieve
fast load times on a small subsection (2-3 screens) of potentially
large data sets and provide the ability (for no reason other than its
possibility) to scroll through them all.

> 1. Skip the ContentProvider, directly call the SQLite database using a
> limit clause, but with your own CursorFactory where you return your own
> SQLiteCursor subclass that uses respond() to coordinate limits with the
> ListView. When the ListView is scrolled near the bottom, you tell your
> custom Cursor to expand its limit range. And, you hope this all doesn't
> take too damn long.
>
> 2. Clone or subclass MergeCursor to allow you to add new Cursors to its
> collection on the fly. Have your ContentProvider somehow hack in a limit
> constraint into its API (e.g., if you aren't using ORDER BY, put the
> limit clause there). When your ListView is scrolled near the bottom, run
> a fresh query for the next set of rows, and add the resulting cursor to
> the MergeCursor. You may need to invalidate() the ListView to get it to
> recognize the newly available rows.
>
> 3. Same as #2, but try a MatrixCursor or CursorWrapper instead.
>
> 4. Roll your own Cursor class that deals with your targeted set of
> results. In particular, it would report 50,000 for getCount(), but
> internally, it would run *its own queries* of the ContentProvider as
> needed based on moveNext() and moveToPosition() to have a window of data
> around the targeted row. You could then have your own caching algorithms
> so you would not need 50,000 records' worth of data in RAM if the user
> does a fling over the whole list. You'll see examples of creating custom
> Cursors using CursorWrapper and such in the Advanced Android book.
>
> 5. Just don't put 50,000 items in a list.

These all seem like great options. I will do some reading over them -
particularly option 4, as it sounds exactly like what I am looking
for.

As an aside, what is there any disadvantage in using a ContentProvider
where data doesn't need to be exposed to other applications? Obviously
use of the limit clause is one issue, but this could be overcome with
uri based pagination, I'd assume.

Thanks again for your help - it is invaluable.

Kind Regards,

Matt

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to