title: How to store checkbox checked Values in ArrayList in Android
body: <p>I want to store the checkbox checked values of <code>ExpandableListView</code> child in array list but I am unable to do this. The <code>ArrayList</code> only gives me the last checked value but I want to store all the checked values of checkbox.</p>
  
  <pre><code>package com.zobrando.contests;
  
  import android.app.Activity;
  import android.content.Context;
  import android.content.SharedPreferences;
  import android.graphics.Typeface;
  import android.preference.PreferenceManager;
  import android.util.Log;
  import android.view.LayoutInflater;
  import android.view.Menu;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.AdapterView;
  import android.widget.BaseAdapter;
  
  
  public class RightDrawerListAdapter extends BaseExpandableListAdapter {
  
  private Context context;
  String xid;
  private List&lt;String&gt; navDrawerItems;
  private ArrayList&lt;RightNanDrawerItems&gt; childItems;
  HashMap&lt;String, List&lt;String&gt;&gt; popuplist;
  boolean checkBoxStates[];
  
  HashMap&lt;Integer, boolean[]&gt; mChildCheckStates = new HashMap&lt;Integer,     boolean[]&gt;();
  private static final Integer[] Icons = {
          R.drawable.trophy,
          R.drawable.buld,
          R.drawable.brand,
          R.drawable.target,
          R.drawable.age,
          R.drawable.participants,
          R.drawable.reward
  };
  CheckBox checkBox;
  
  public RightDrawerListAdapter(Context context, List&lt;String&gt;   navDrawerItems,HashMap&lt;String, List&lt;String&gt;&gt; popuplist){
      this.context = context;
      this.navDrawerItems = navDrawerItems;
      this.childItems = childItems;
      this.popuplist = popuplist;
  }
  
  @Override
  public Object getChild(int groupPosition, int chlidPosition) {
      //String pos = String.valueOf(groupPosition);
      return this.popuplist.get(this.navDrawerItems.get(groupPosition))
              .get(chlidPosition);
  }
  
  @Override
  public Object getGroup(int groupPosition) {
  
      return this.navDrawerItems.get(groupPosition);
  }
  
  @Override
  public int getGroupCount() {
  
      return this.navDrawerItems.size();
  }
  
  @Override
  public long getChildId(int groupPosition, int childPosition) {
      return childPosition;
  }
  
   @Override
   public long getGroupId(int groupPosition) {
      return groupPosition;
   }
  
  @Override
  public View getChildView(final int groupPosition, final int childPosition,
                           boolean isLastChild, View convertView, ViewGroup  parent) {
  
      final String childText = getChild(groupPosition,      childPosition).toString();
      final ArrayList&lt;String&gt; selectedStrings = new ArrayList&lt;String&gt;();
  
  
      if (convertView == null) {
          LayoutInflater infalInflater = (LayoutInflater) this.context
                  .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          convertView = infalInflater.inflate(R.layout.pop_up_list_items,  null);
      }
      //selectedStrings.clear();
  
      TextView txtTitle = (TextView) convertView.findViewById(R.id.popuplist);
      checkBox = (CheckBox)convertView.findViewById(R.id.checked);
  
      //checkBox.setText(childid);
      txtTitle.setText(childText);
  
      checkBox.setOnCheckedChangeListener(new     CompoundButton.OnCheckedChangeListener() {
          @Override
           public void onCheckedChanged(CompoundButton buttonView, boolean   isChecked) {
                       if (isChecked){
                          xid = childText.substring(0,1);
                          xid = xid.replace("-", "");
                          selectedStrings.add(xid);
                      }
  
                  Toast.makeText(context,xid+"xid",Toast.LENGTH_LONG).show();
                  Toast.makeText(context,selectedStrings+"Seleted   Strings",Toast.LENGTH_LONG).show();                                               
                  SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
                  SharedPreferences.Editor editor = pref.edit();
                  editor.putString("xid", mChildCheckStates+"");
                  editor.apply();
          }
      });
      //checkBox.setOnCheckedChangeListener(new   CheckchangeListener(groupPosition));
      return convertView;
  }
  
  
  @Override
  public int getChildrenCount(int groupPosition) {
      return this.popuplist.get(this.navDrawerItems.get(groupPosition))
              .size();
  }
  
  @Override
  public View getGroupView(int groupPosition, boolean isExpanded,
                           View convertView, ViewGroup parent) {
      String headerTitle =  getGroup(groupPosition).toString();
      if (convertView == null) {
          LayoutInflater infalInflater = (LayoutInflater) this.context
                  .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          convertView =    infalInflater.inflate(R.layout.right_drawer_list_items, null);
      }
  
      ImageView imgIcon = (ImageView) convertView.findViewById(R.id.icon);
      imgIcon.setImageResource(Icons[groupPosition]);
      TextView txtTitle = (TextView) convertView.findViewById(R.id.title);
  
      imgIcon.setImageResource(navDrawerItems.get(groupPosition).getIcon());
      txtTitle.setText(headerTitle);
  
      return convertView;
  }
  
  @Override
  public boolean hasStableIds() {
      return false;
  }
  
  @Override
  public boolean isChildSelectable(int groupPosition, int childPosition) {
      return true;
  }
  
  class CheckchangeListener implements CompoundButton.OnCheckedChangeListener     {
      private int position;
  
  
      public CheckchangeListener(int position) {
          // TODO Auto-generated constructor stub
          this.position= position;
  
  
      }
  
      @Override
      public void onCheckedChanged(CompoundButton buttonView,
                                   boolean isChecked) {
          // TODO Auto-generated method stub
          if (isChecked) {
              //updateyour list and database here
  
          } else {
              //updateyour list and database here
  
          }
  
      }
  }
  </code></pre>
  
  <p>}</p>