title: Android SharedPreferences Example
body: <p>I'm trying to learn SharedPreferences, but I'm getting an error.</p>
  
  <p>My layout has one button that reeacts to the method <code>doThis</code></p>
  
  <p>This is my java:</p>
  
  <pre><code>package com.example.sharedprefs;
  
  import android.app.Activity;
  import android.content.SharedPreferences;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.Toast;
  
  public class MainActivity extends Activity {
      int i = 0;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
      }
  
      public void doThis (View view){
          i++;
          SharedPreferences sharedPref = getSharedPreferences("FileName",MODE_PRIVATE);
          SharedPreferences.Editor prefEditor = sharedPref.edit();
          prefEditor.putInt("userChoice",i);
          prefEditor.commit();
          int number = sharedPref.getInt("userChoice", 0);
          Toast.makeText(getApplicationContext(), number, Toast.LENGTH_LONG).show();
      }
  
  }
  </code></pre>
  
  <p>Only thing I can pinpoint in logcat is <code>10-15 19:28:17.707: E/AndroidRuntime(16657): Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x1
  </code></p>