Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Well, there are some problems in your code. This <a href="http://www.kaloer.com/android-preferences" rel="nofollow">tutorial</a> is good for creating preferences. Also, if you want to change the preferences outside the <code>PreferenceActivity</code> you should use the Editor For example:</p> <pre><code>Editor e = PreferenceManager.getDefaultSharedPreferences(getBaseContext()).edit(); e.putBoolean(Preferences."PREF_SMS_ON", true); e.commit(); </code></pre> <p>I hope it helps</p> <h2>The reply to your comment</h2> <p>well, the thing is that you are using <code>PreferenceActivity</code>, which as the documentation show in <a href="http://developer.android.com/reference/android/preference/PreferenceActivity.html" rel="nofollow">here</a> it is used for showing a visual style of the preferences. Also, as it is indicated <a href="http://developer.android.com/reference/android/preference/PreferenceActivity.html" rel="nofollow">here</a>, "the preferences will automatically save to <code>SharedPreferences</code> as the user interacts with them". It gave me the impression that you wanted to change preferences outside the <code>PreferenceActivity</code> (which is not wrong), but you say thats not what you are wanting to do. </p> <p>However, I do notice that your <code>PreferenceActivity</code> is not loading the preferences from your resource file, for that you need to add <code>addPreferencesFromResource(R.xml.settings);</code> in your <code>onCreate</code>, for example. But, like I said, your preferences will only change automatically if the user interacts with this activity directly. I hope that helps.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload