title: Android CheckBoxPreference - un/check all preferences
body: <p>I have a <code>PreferenceScreen</code> containing only <code>CheckBoxPreferences</code> (categories to select). I need an option to check/uncheck all of them. I have the following code that does the job but there is one problem: checkboxes on the screen are not updated - I'd need to call some invalidate on the view or something.</p>
  
  <p>Here is my present code:</p>
  
  <pre><code>    private void checkAll() {
          SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
          SharedPreferences.Editor editor = settings.edit();
          @SuppressWarnings("unchecked")
          Map&lt;String, Boolean&gt; categories = (Map&lt;String, Boolean&gt;) settings.getAll();
          for(String s : categories.keySet()) {
              editor.putBoolean(s, true);
          }
          editor.commit();
      }
  
      private void uncheckAll() {
          SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
          SharedPreferences.Editor editor = settings.edit();
          @SuppressWarnings("unchecked")
          Map&lt;String, Boolean&gt; categories = (Map&lt;String, Boolean&gt;) settings.getAll();
          for(String s : categories.keySet()) {
              editor.putBoolean(s, false);
          }
          editor.commit();
          this.restart();
      }
  </code></pre>
  
  <p>This code works fine but I'd need to refresh the view somehow to see the result imediatelly (not just after closing and re-starting the settings activity).</p>
  
  <p>Thank You all for any advice!</p>