Reputation: 3417
I am saving records from arrayList and whenever I goes back to the activity where I used that arrayList and save another record, the previous record was also saved together with the new one. How can I empty the arrayList?
ArrayList<String> arraySubBrand = new ArrayList<String>();
for (int j=0; j<checkSelected.length; j++) {
if(checkSelected[j]==true) {
String values = BrandListAdapter.mListItems.get(j);
Cursor rSubBrand = databaseHandler.getReport_SubBrandCode(values);
if(rSubBrand.moveToFirst()) {
SubBrandCode = rSubBrand.getString(rSubBrand.getColumnIndex(Constants.SUBBRAND_CODE));
}
arraySubBrand.clear();
arraySubBrand.add(SubBrandCode);
String subBrand = arraySubBrand.toString();
subBrand = subBrand.replace("[", "");
subBrand = subBrand.replace("]", "");
databaseHandler.SaveSubBrand(new Cons_iReport (ReportCode, subBrand));
}
}
Upvotes: 0
Views: 91