I have this code:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<CheckBoxPreference android:key="notification_settings"
android:text="@string/impostazione"
android:id="@+id/save_check"
android:summary="@string/notification_title"
android:defaultValue="false"
></CheckBoxPreference>
</PreferenceScreen>
now i need to get Checkbox value in FragmentA:
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
and now?
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
boolean isChecked = sharedPreferences.getBoolean(getString(R.string.notification_settings), false);
Try this way,hope this will help you to solve your problem.
sharedPreferences.getBoolean("notification_settings",false)
getBoolean() : required two parameter one is key and another is default value
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With