Reputation: 1638
Can anyone please tell me difference between AsyncTaskLoader vs AsyncQueryHandler?
I want to use AsynTaskLoader in my app.. The existing one in my app is AsyncQueryHandler..
Am I right about that AsyncTaskLoader is the replacement of AsyncQueryHandler?
Correct me If I am wrong.. I am very new to android.
Upvotes: 4
Views: 1877
Reputation: 1062
CursorLoader
is a subclass of AsyncTaskLoader
. And LoaderManager & CursorLoader only provide a way to access results of async invoked query() operations on ContentResolvers. Other ContentResolver operations are still synchronous.
However, AsyncQueryHandler
invokes all ContentResolver calls asynchronously. Not just query, but also insert, delete, update.
Upvotes: 1
Reputation: 72321
If you read the docs :
A helper class to help make handling asynchronous ContentResolver queries easier.
Abstract Loader that provides an AsyncTask to do the work. See Loader and LoaderManager for more details.
So they are pretty different. AsyncQueryHandler
is used for querying/inserting asynchronously into a ContentResolver
, and the AsyncTaskLoader
it is an implementation of the new Loader
mechanism (introduced in API Level 11) which uses an AsyncTask
do to any kind of background processing (HTTP, SQL, etc).
You should also look at CursorLoader
, maybe it is what you need.
I would say that if you just want to read from a ContentResolver
you should use a CursorLoader
, but if you want to insert, delete etc. into that ContentResolver
, maybe it is better to use the AsyncQueryHandler
.
Upvotes: 7