Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AsyncTaskLoader vs Asyncqueryhandler

Tags:

android

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.

like image 437
Ashokchakravarthi Nagarajan Avatar asked Feb 14 '23 20:02

Ashokchakravarthi Nagarajan


1 Answers

If you read the docs :

AsyncQueryHandler :

A helper class to help make handling asynchronous ContentResolver queries easier.

AsyncTaskLoader :

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.

like image 180
Ovidiu Latcu Avatar answered Feb 26 '23 17:02

Ovidiu Latcu