So I want to save CheckBox state via SharedPreferences in RecyclerView adapter class like this:

```
checkBox.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (checkBox.isChecked()){
                        title.setPaintFlags(title.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
                        title.setAlpha(0.5f);
                        PreferenceManager.getDefaultSharedPreferences(c).edit().putBoolean("checkBox", checkBox.isChecked()).commit();
                    } else if (!checkBox.isChecked()){
                        title.setPaintFlags(0);
                        title.setAlpha(0.8f);
                        PreferenceManager.getDefaultSharedPreferences(c).edit().putBoolean("checkBox", checkBox.isChecked()).commit();
                    }
                }
            });

```

Dont' mind the paint flags.

And I'm retrieving the data in my activity like this (in onCreate):

```
 checkBox = (CheckBox) findViewById(R.id.checkBoxDoneOrNotNaListi);
        boolean checked = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("checkBox", false);
        checkBox.setChecked(checked);

```

And getting NullPointerException

```
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.CheckBox.setChecked(boolean)' on a null object reference

```

What did I do wrong?