title: NullPointerException on SharedPreferences in Button OnClick
body: <p>I'm trying to update a shared preference of whether or not a user has checked a box to not display a welcome screen anymore. I access my shared preferences my onClick listener for a button. I'm getting a Null Pointer Exception and I don't know how to fix it?</p>
  
  <p>Here is my code....</p>
  
  <pre><code>public class WelcomeScreenActivity extends Activity {
  
  
  SharedPreferences mPrefs;
  final String welcomeScreenShownPref = "welcomeScreenShown";
  
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      setContentView(R.layout.welcomescreen);
  
  
      final Button button = (Button) findViewById(R.id.welcomecontinue);
      button.setOnClickListener(new View.OnClickListener() {
          public void onClick(View v) {
              CheckBox cb = (CheckBox) findViewById(R.id.welcomecheckbox);
              if(cb.isChecked()){
                  SharedPreferences.Editor editor = mPrefs.edit();
                  editor.putBoolean(welcomeScreenShownPref, true);
                  editor.commit(); // Very important to save the preference
                  Intent intent = new Intent(WelcomeScreenActivity.this, MainActivity.class);
                  startActivity(intent);
              } else if(!cb.isChecked()){
                  SharedPreferences.Editor editor = mPrefs.edit();
                  editor.putBoolean(welcomeScreenShownPref, false);
                  editor.commit(); // Very important to save the preference
                  Intent intent = new Intent(WelcomeScreenActivity.this, MainActivity.class);
                  startActivity(intent);
              }
          }
      });
  
  
  }
  
  }
  </code></pre>
  
  <p>Can anyone shed some light into this?</p>