title: Changing background colour with SharedPreference in Android
body: <p>I want to change the background color of my app with a button. It should switch between two colors, for this I used SharedPreference, but >I don't know yet how to store the boolean for switching..
  I got this:</p>
  
  <pre><code>public void method1(View view) {
  
      SharedPreferences settings = getSharedPreferences(PREFS, 0);
      SharedPreferences.Editor editor = settings.edit();
      editor.putBoolean("modus", !modus);
      editor.commit();
      if (settings.getBoolean("modus", false)) {
          int i = Color.GREEN;
          LinearLayout layout = (LinearLayout) findViewById(R.id.mylayout);
          layout.setBackgroundColor(i);
      } else {
          int j = Color.BLUE;
          LinearLayout layout = (LinearLayout) findViewById(R.id.mylayout);
          layout.setBackgroundColor(j);
      }
  }
  </code></pre>