Good day, friends.
I'm wanting to build preference activity.
In the main activity I've wrote:
I wrote in string.xml:
In my_tuner.xml I've wrote:
And in preference activity I've made:
I've checked and unchecked checkbox, but its value is independent to the value in the main activity.
"loopSound" in main activity remains false despite of checked checkbox.
As I understand, my preference activity stores value in the another workspace, not in the "My preferences".
What's solution?
I'm wanting to build preference activity.
In the main activity I've wrote:
Code:
localPreferences = getSharedPreferences("My preferences", 0);
loopSound = localPreferences.getBoolean(getString(R.string.keyLoopSound), false);
Code:
<string name="preferenceTitle">My Tuner options</string>
<string name="keyLoopSound">keyLoopSound</string>
<string name="valueLoopSound">Loop sound</string>
Code:
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" android:title="@string/preferenceTitle">
<CheckBoxPreference android:key="@string/keyLoopSound" android:title="@string/valueLoopSound" />
</PreferenceScreen>
Code:
addPreferencesFromResource(R.xml.my_tuner);
I've checked and unchecked checkbox, but its value is independent to the value in the main activity.
"loopSound" in main activity remains false despite of checked checkbox.
As I understand, my preference activity stores value in the another workspace, not in the "My preferences".
What's solution?