I’m trying to copy elements from one arrayList into another, I starting getting errors in my app and I think the problem is that I was doing shallow copies.
How can I add an item from one array into another doing a deep copy/clone?
This is how I was copying the elements up to now:
public ArrayList<ResolveInfo> myAppsArr = new ArrayList();
public ArrayList<ResolveInfo> allAppsArr = new ArrayList();
myAppsArr.add(allAppsArr.get(0));
ResolveInfo has a constructor that creates new duplicate object for you:
It appears this constructor was only added in API 17, you can try the generic clone method:
Or you can create a method that manually creates a new ResolveInfo object since all of the member data is public.