I am running three AsyncTask()
each AsyncTask
create an object of another class.
This is how i am creating instance of a class from doInBackground()
,
DOM domObject = new DOM;
Now, there is a class level ArrayList
in my DOM
class,
public class DOM {
public static ArrayList<HashMap<String, Object>> tempNewsArray = new ArrayList<>();
My main class run three AysncTask
object so three separate instance of DOM
class should be created for each AsyncTask
.
On each execution of AsyncTask
, some data is added into the ArrayList
.
Example,
First AsynTask
executed,
Some Data added in ArrayList
.
Second AsyncTask
executed,
Some Data added in ArrayList
(Previous Data should not be there in ArrayList
)
But the problem is, the data from the previous instance of DOM
class is still there in the ArrayList
and not removed when new instance of DOM
class is created by another AysnTask
instace.
Why is this happening ?
Example,
First instance of DOM
class created by first Asynctask
,
Some data is added in ArrayList.
Second instance of DOM
class is created by second Asynctask
instance,
Some new data is added in the ArrayList
but the previous data from previous instances is still there.
Why so ?