title: Android Studio SharedPreferences - How I can save boolean?
body: <p>I would like to know how I can store a boolean with SharedPreferences and disable a button. If you restart the app, the button should remain disabled.
  Here is my Code, but something is wrong.</p>
  
  <pre><code>public class Pass extends AppCompatActivity implements View.OnClickListener {
  
  private Button btn1;
  private EditText text1;
  
  private SharedPreferences speicher;
  private SharedPreferences.Editor editor;
  
  final boolean enabled = false;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_pass);
  
      btn1 = (Button) findViewById(R.id.button);
      btn1.setOnClickListener(this);
  
      text1 = (EditText) findViewById(R.id.editText);
      text1.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
  
      speicher = getApplicationContext().getSharedPreferences("Daten", 0);
      editor = speicher.edit();
  
       speicher = getSharedPreferences("Daten", 0);
       speicher.getBoolean("Data1", enabled);
  
  }
  
  
  public void onClick (View view){
  
  
      if (text1.getText().toString().equals("pass")){
          AlertDialog ad = new AlertDialog.Builder(this).create();
          ad.setMessage("Great");
          ad.show();
          Intent intent = new Intent(this,Popup.class);
          startActivity(intent);
  
          btn1.setEnabled(enabled);
  
          editor.putBoolean("Data1", enabled);
          editor.commit();
  
      }else{
          String message = "Wrong";
          Toast.makeText(this,message, Toast.LENGTH_LONG).show();
      }
  }
  
  }
  </code></pre>
  
  <p>I hope you can help me.</p>
  
  <p>since</p>
  
  <p>Strecki</p>