SharedPreferences variable always returns false <p>I am using a Preference Fragments following the step by step guide on <a href="http://developer.android.com/intl/es/guide/topics/ui/settings.html#Fragment" rel="nofollow">Android guide</a>. </p> <p>I am trying to set some preferences using this fragment, so later on the code I can check the value of each variable to perform actions accordingle. </p> <p>Mi Preference fragment is working fine. However, when I try to recover the value of a CheckedBoxPreference somewhere else on the code, it always returns false.</p> <p>This is the preference xml file :</p> <pre><code>&lt;PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" android:persistent="true" &gt; &lt;PreferenceCategory android:title="NOTIFICACIONES" android:key="pref_key_storage_settings"&gt; &lt;CheckBoxPreference android:key="sendMail" android:defaultValue="false" android:persistent="true" android:summary="Send emails to contacts" android:title="E-mail"/&gt; &lt;/PreferenceCategory&gt; &lt;/PreferenceScreen&gt; </code></pre> <p>This is the class I've done to use SharedPReferences</p> <pre><code>public class Prefs{ private static Prefs myPreference; private SharedPreferences sharedPreferences; private static final String NOMBRE_PREFERENCIAS = "MisPreferencias"; public static Prefs getInstance(Context context) { if (myPreference == null) { myPreference = new Prefs(context); } return myPreference; } private Prefs(Context context) { sharedPreferences = context.getSharedPreferences(NOMBRE_PREFERENCIAS,context.MODE_PRIVATE); } public Boolean getBoolean(String key) { boolean returned = false; if (sharedPreferences!= null) { returned = sharedPreferences.getBoolean(key,false); } return returned; } } </code></pre> <p>And this is how I check if the options is selected, so I can send/or not emails to clients</p> <pre><code>Prefs preferences = Prefs.getInstance(getApplicationContext()); if(preferences.getBoolean("sendMail") { // .... send email } </code></pre> <p>As I said, what is strange is that It is persistent on the settings fragment ( if I select the option sendEmmail, it is selected even if I close the app and reopen it. However, when I check the value using my method, it always returns false.</p> <p>What am I doing wrong?</p> <p>Thank you</p>