i'm trying to remove all elements from mapSet but i getting ConcurrentModificationException so i have some checked boxes and their vlues is in mapset but i want to when press submit button it removes all of mapset values .
my code :
 sumbit.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if(checkNoAttndance.isChecked()==true){
                  for (Map.Entry<Integer, Integer> mapEntry : checkBoxState
                          .entrySet()){
                          checkBoxState.remove(mapEntry.getKey());
                          }
            }
            else if (checkBoxState.isEmpty()) {
                Toast.makeText(activity, "الرجاء اختيار اسماء الطلبة الغائبون ",
                        Toast.LENGTH_SHORT).show();
            }
            else {
                ProgressDialog progressDialog = new ProgressDialog(activity);
                progressDialog
                        .setMessage("جاري ارسال البيانات ، الرجاء الانتظار");
                progressDialog.show();
                SendListSync asynTask = new SendListSync(context, activity,
                        checkBoxState, progressDialog);
                asynTask.execute();
            }
        }
    });
 
    