Reputation: 5763
I have two ArrayLists and I want to remove all objects of first ArrayList with reference to second ArrayList. I know I can use removeAll() method but it is returning false.Both ArrayLists are of same type. any alternatives of removeAll()
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
if (successfullyAssigned) {
ArrayList<CustomDataModel> dataList = adapter.getDataSet();
Boolean deleted = dataList.removeAll(taskDataList);
Log.d("LogTag", "deleted ? " + deleted);
setPreference(getPrefName(), dataList);
}
}
public ArrayList<CustomDataModel> getDataSet() {
return dataSet;
}
private class AssignTask extends AsyncTask<ArrayList<CustomDataModel>, Void, Void> {
ProgressDialog progressDialog;
ArrayList<CustomDataModel> taskDataList;
Boolean successfullyAssigned;
@SafeVarargs
@Override
protected final Void doInBackground(ArrayList<CustomDataModel>... callData) {
taskDataList = callData[0];
Upvotes: 0
Views: 525
Reputation: 12513
There are three reasons this can happen
CustomDataModel.equals()
.Upvotes: 1