1. Download our Official Android App: Forums for Android!

Apps Preference is saved in wrong place

Discussion in 'Android Development' started by QuickNick, Aug 5, 2011.

  1. QuickNick

    QuickNick Member
    Thread Starter
    Rank:
    None
    Points:
    16
    Posts:
    32
    Joined:
    Jun 27, 2011

    Jun 27, 2011
    32
    2
    16
    Good day, friends.

    I'm wanting to build preference activity.
    In the main activity I've wrote:
    Code (Text):
    1.  
    2. localPreferences = getSharedPreferences("My preferences", 0);
    3. loopSound = localPreferences.getBoolean(getString(R.string.keyLoopSound), false);
    I wrote in string.xml:
    Code (Text):
    1.  
    2.     <string name="preferenceTitle">My Tuner options</string>
    3.     <string name="keyLoopSound">keyLoopSound</string>
    4.     <string name="valueLoopSound">Loop sound</string>
    In my_tuner.xml I've wrote:
    Code (Text):
    1. <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" android:title="@string/preferenceTitle">
    2.     <CheckBoxPreference android:key="@string/keyLoopSound" android:title="@string/valueLoopSound" />
    3. </PreferenceScreen>
    And in preference activity I've made:
    Code (Text):
    1. 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?
     

    Advertisement

Share This Page

Loading...