I dont know what is wrong with my code, I read multiple sources and
made sure I did it the correct way
Everything goes well until the user clicks on the preference,
disabling it to "false", and then it crashes when I access the value
in another class. This code works for retrieving string values from
preferences from a ListPreference and EditTextPreference (changing the
function and "getBoolean" to String type), but not for
CheckBoxPreference.
Here is my code for the segment:
XML
<CheckBoxPreference
                        android:key="GPS_Sensor"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:title="@string/GPS_checkbox"
                        android:defaultValue="true"
                        />

Java:
public static boolean getGPSOption(Context context){
                return
PreferenceManager.getDefaultSharedPreferences(context).getBoolean(GPS_SENSOR,
true);
        }

where:
GPS_SENSOR = "GPS_Sensor"

I call it in another class, in "onCreate()" as:
_GPS_CHECK = Prefs.getGPSOption(this);


It is extremely frustrating not knowing what is wrong.
Any help would be extremely appreciated!

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to