title: RecyclerView checkbox deselect all?
body: <p>I'm wondering how I'd be able to use a button in another class to deselect all checkboxes in my 3 recyclerviews(Tablayout, one recyclerview per tab). I have saved the checked value in shared pref as shown here:</p>
  
  <pre><code>public class MyRecyclerAdapter extends RecyclerView.Adapter&lt;MyViewHolder&gt; {
  
  Context mContext;
  ArrayList&lt;Workout&gt; workout;
  SharedPreferences prefs;
  int firstSecondOrThird;
  int colorResId = R.color.defaultcard;
  
  public MyRecyclerAdapter(Context context, ArrayList&lt;Workout&gt; workout, int thePosition) {
      mContext = context;
      this.workout = workout;
      this.firstSecondOrThird = thePosition;
  }
  // INITIALIZE HOLDER
  @Override
  public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
      View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.workout_item, null);
      MyViewHolder holder = new MyViewHolder(view);
  
      return holder;
  }
  
  //BIND DATA TO VIEWS
  @Override
  public void onBindViewHolder(MyViewHolder holder, final int position) {
      holder.exercise.setText(workout.get(position).getExercise());
      holder.percent.setText(workout.get(position).getPercent());
      holder.reps.setText(workout.get(position).getReps());
      holder.weight.setText(workout.get(position).getWeight());
      holder.check1.setOnCheckedChangeListener(null);
  
      final Workout isCheck = workout.get(position);
  
      prefs = mContext.getSharedPreferences("checkState", Context.MODE_PRIVATE);
         holder.check1.setChecked(prefs.getBoolean(firstSecondOrThird+"checkState"+position, false));
      isCheck.setCheck1(prefs.getBoolean(firstSecondOrThird+"checkState"+position, false));
  holder.check1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
  
              prefs.edit().putBoolean(firstSecondOrThird+"checkState"+position, isChecked).apply();
          }
      });
  
  }
  </code></pre>
  
  <p>And here is where I try to clear shared pref, which I thought would also clear all checkmarks:</p>
  
  <pre><code>mButton = (Button) findViewById(R.id.button2);
  
      mButton.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
  
              prefs.edit().clear();
              prefs.edit().apply();
              Toast.makeText(getApplicationContext(), "Checkboxes Cleared.", Toast.LENGTH_LONG).show();
  
          }
      });
  }
  </code></pre>
  
  <p>Unfortunately, after clicking the button, all checkboxes that were previously selected are still selected. Thanks in advance!</p>
  
  <p>EDIT: I tried to add an if statement to see if that would work, but now it doesn't load the saved checkmarks are all, even when the button isn't clicked... lol</p>
  
  <pre><code>prefs = mContext.getSharedPreferences("checkState", Context.MODE_PRIVATE);
      String restoredCheck = prefs.getString("checkState", null);
      if (restoredCheck != null) {
          holder.check1.setChecked(prefs.getBoolean(firstSecondOrThird+"checkState"+position, false));
      } else holder.check1.setChecked(false);
  </code></pre>