Loaders don't add a lot more overhead over what is required to query a
content provider for a cursor, so feel free to use them for one-shot
operations.

Of course be prepared for this one-shot operation to continue executing
across activity instances if your activity gets restarted.  If you aren't
going to deal well with this case, I'm not sure a loader really buys you
much over just doing the query in an async task.

On Tue, Sep 20, 2011 at 5:27 PM, goosedroid <[email protected]> wrote:

> I'm just getting familiar with the Loader framework, but they seem
> geared for queries where you keep the cursor around, so the Loader can
> manage / requery when changes occur to the underlying Uri.
>
> But what about those queries that are one-shot type things, where you
> need the data in the cursor for some reason, and then just want to
> close it right away?
>
> I guess I could do something like this in
> LoaderManager.LoaderCallbacks.onLoadFinished(Loader<D> loader, D data)
>
> {
>    ... get required data out of cursor
>    getLoaderManager().destroyLoader(loader.getId());
> }
>
> This seems kinda heavy though in situations where i expect to be doing
> many of these kinds of queries. I would expect a bunch of bookkeeping
> to get updated, as well as GC activity too.
>
> Should I keep using AsyncQueryHandler for this scenario?
>
> --
> 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
>



-- 
Dianne Hackborn
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

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