title: Read current value of switchpreference
body: <p>I am using a switch statement to check the origin of the preference.</p>
  
  <pre><code>public class SettingsActivity extends PreferenceActivity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  
  // Display the fragment as the main content.
  getFragmentManager().beginTransaction()
          .replace(android.R.id.content, new SettingsFragment())
          .commit();
  PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
  
  getFragmentManager().beginTransaction().replace(android.R.id.content,
          new SettingsFragment()).commit();
  }
  
  public static class SettingsFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      addPreferencesFromResource(R.xml.preferences);
  }
  
  public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
      Preference pref = findPreference(key);
      switch(key) {
          case "key_video_quality":
              Log.i("Tag1", "Video quality button pressed");
              break;
          case "key_video_length":
              Log.i("Tag2", "Video length button pressed");
              break;
          case "key_auto_save":
              Log.i("Tag3", "Auto save button pressed");
              break;
          case "key_dark_mode":
              Log.i("Tag4", "Dark mode button pressed");
              break;
          }
      }
  }
  </code></pre>
  
  <p><code>key_auto_save</code> is never triggered, and <code>key_dark_mode</code> is, they are both <code>SwitchPreferences</code>.</p>
  
  <p>Is there a method to check the current value of switch preference when it is pressed so i can decide to switch on/off a dark theme for my application? As i am using it as a general <code>Preference</code> i don't think <code>isChecked()</code> applies here.</p>
  
  <p>Also, i'm unsure on the <code>key_auto_save</code> problem, the key is correct.</p>