I’m developing an app in which I pretend to invoke a REST service for typical CRUD operations. Since I want to separate the requests processing from the UI thread, I’m planning to use an AsyncTask to do the separate work. However, my question here is: how should I desing my AsyncTask(s) model? Should I use one AsyncTask for all CRUD operations (is this even feasible?), or use i.e. 4 AsyncTasks (create, delete, update, retrieve)?
Thanks in advance
It is really up to you, and perhaps, the REST service which you are consuming.
Some things to consider:
AsyncTask?AsyncTask? I would tend to think that it would be easier to read if you did oneAsyncTaskfor each operation. (ie, CreateTask, UpdateTask…)Personally, I would create 4 distinct
AsyncTask‘s, and any reusable code I might put in a base class, but again, it is really up to you for what is going to work best for you.