I am trying to get and set the listPreference value from different actions and not work.
When I read and write it from my main action, it only saves what I write, so I assume that listPreference was not configured correctly when I left it, because it works inside my preference activity, there is no problem.
I saw some links on the CharSequence developer website with getValue and getEntryValues, but I was not lucky that they worked correctly too.
Here is my code for clicking a button and setting the listpreference value, after which it triggers the intention to switch actions:
The main activity, an attempt to set the listpreference value for the first index value;
SharedPreferences settings = getSharedPreferences("PreferenceXML",
MODE_PRIVATE);
SharedPreferences.Editor editor = settings.edit();
editor.putString("ListPreferenceInXML", "1");
editor.commit();
String levelCheck = settings.getString("ListPreferenceInXML","1");
, , , listPreference , , . , Preference, , ListPreference ( , )
, ListPreference:
SharedPreferences settings = getSharedPreferences("PreferenceXML",
MODE_PRIVATE);
Toast.makeText(this, settings.getString("ListPreferenceInXML","1"), 1000).show();