title: Saving checkbox state from Recyclerview
body: <p>I have checkbox in my <code>Recyclerview</code>, now i am able to click it and show a snackbar. But can anyone help me to save the state of the checkbox from the recyclerview.</p>
  
  <p>I had created an onclicklistener in <code>onBindViewHolder</code> of the recyclerview adapter.</p>
  
  <pre><code> private SparseBooleanArray mCheckedItems = new SparseBooleanArray();
          @Override
          public void onBindViewHolder(final RecyclerViewHolder viewHolder, int i) {
              // get the single element from the main array
              DisplayImageOptions options = new DisplayImageOptions.Builder()
                      .showImageOnLoading(R.drawable.mirlogo)
                      .showImageForEmptyUri(R.drawable.gallery_no_image)
                      .showImageOnFail(R.drawable.gallery_image_fail)
                      .cacheInMemory(true)
                      .cacheOnDisk(true)
                      .considerExifParams(true)
                      .bitmapConfig(Bitmap.Config.RGB_565)
                      .build();
  
              final String images = HomeDataImages.IMAGES[i];
              // Set the values
  
              ImageLoader.getInstance()
                      .displayImage(images, viewHolder.mImage, options);
  
               viewHolder.mCheck.setChecked(mCheckedItems.get(i));
          Log.d("Position=", String.valueOf((mCheckedItems.get(i))));
  
          viewHolder.mCheck.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
  
              @Override
              public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
  
                  int position = viewHolder.getAdapterPosition();
                  mCheckedItems.put(position, isChecked);
                  Log.d("Checked Array = ", String.valueOf(mCheckedItems));
  //                viewHolder.mCheck.setChecked(mCheckedItems);
  //error comes here setChecked(boolean) cannot be applied to SparseBooleanArray
                 if (isChecked){
                  Snackbar snackbar = Snackbar.make(viewHolder.itemView, "Item Favorited", Snackbar.LENGTH_SHORT);
                  snackbar.show();}
                  else{
                     Snackbar snackbar = Snackbar.make(viewHolder.itemView, "Item Unfavorited", Snackbar.LENGTH_SHORT);
                     snackbar.show();}
                 }
              });
  
      }
  </code></pre>
  
  <p>thanks in advance.</p>