> 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.

Just wanted to let you know that I implemented this method and it is
working beautifully.
My only gripe was that AbstractCursor has moveToPosition marked as
final, so I ended up implementing my own. Can anyone explain why this
would be the case?

Having actually placed some contacts into my phone I've discovered
fast scrolling, so that will be my next step - maybe working off a
sparse cursor of sorts.

> I usually just get an independent SQLiteDatabase object in any component
> (activity, service) that needs one and serialize any concurrent access
> to that object. SQLite should handle the rest, AFAIK.

> I'm not saying it's absolutely the best solution, but I haven't run into
> a problem yet.

I decided to go with a static singleton approach using solely a
synchronized rawQuery method for access to the database, and call it
using utility methods for basic inserts, etc. I'm sure this is
overkill for a phone database (and even moreso for the app im
building!), but I feel like im doing the right thing :) If I find my
app leaking memory, then I'll look at an alternative implementation
(probably a content provider).

It would be really nice if we could get some feedback on thread-safety
db access from the engineers though (i got as far as the native method
and saw nothing in terms of locks).

Anyway, thank you all for your support.

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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to