Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Change this line</p> <pre><code>SharedPreferences preferences = this.getSharedPreferences("us.mattmccoy.meanfind", Context.MODE_PRIVATE); </code></pre> <p>to</p> <pre><code>SharedPreferences preferences; = this.getSharedPreferences("us.mattmccoy.meanfind", Context.MODE_PRIVATE); </code></pre> <p>and put </p> <pre><code>preferences = this.getSharedPreferences("us.mattmccoy.meanfind", Context.MODE_PRIVATE); </code></pre> <p>in <code>onCreate()</code></p> <p>You are trying to use <code>Context</code> before establishing it with <code>onCreate()</code> so you are getting <code>NPE</code> on <code>context</code>. You will also want to move these lines </p> <pre><code>Editor edit = preferences.edit(); boolean autoclear = preferences.getBoolean(autoclearKEY, false); </code></pre> <p>into <code>onCreate()</code> after you initialize <code>preferences</code> or you will get another <code>NPE</code> since <code>preferences</code> will be <code>null</code> until you initialize it. So it should be something like</p> <pre><code>public class MainActivity extends Activity { //saved data stuff needed SharedPreferences preferences; //declare them Editor edit; //private data using saved data String autoclearKEY = "us.mattmccoy.meanfind.AUTOCLEAR"; boolean autoclear; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); SharedPreferences preferences; = this.getSharedPreferences("us.mattmccoy.meanfind", Context.MODE_PRIVATE); Editor edit = preferences.edit(); //initialize them boolean autoclear = preferences.getBoolean(autoclearKEY, false); addListenerBoxes(); if(autoclear == true){ acBox.setChecked(true); }else{ acBox.setChecked(false); } </code></pre> <p>If this doesn't solve your problem then please post full logcat</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload