in my application for Setting screen I am using PreferenceFragment. In this screen i have several checkbox, some checkbox bydefault are non checked. Now in next release I want to set them as checked. so in .xml file i had change value <CheckBoxPreference android:checked="true" android:defaultValue="true"
, and also change Shared preference value according to this. If I install fresh application everything is good. But if I install application from play store and tries to update that application using new signed build, then these check boxes are not selected by default. In this case what to do if want to change value of CheckBoxPreference. Any suggestion will be appreciated. Thanks
Asked
Active
Viewed 61 times
0

PPD
- 5,660
- 12
- 52
- 86
-
I think the problem is with the cache. You have to delete that part from the application data for it to get refreshed – Arahasya Oct 28 '18 at 08:07
-
https://stackoverflow.com/questions/52264990/clearing-app-data-and-cache-when-releasing-new-update – Arahasya Oct 28 '18 at 08:08
-
@Arahasya. Thanks for suggestion. I had fixed this issue using SharedPreference. I had changed by default sharedPreference value to true and in PreferenceFragment I am checking value of sharedPreference. If sharedPreference value is true I am setting check box as selected ((CheckBoxPreference) mAutoUpdatePref).setChecked(true); – PPD Oct 28 '18 at 08:27
-
Try changing the keys of sharedpreferences. It's possible the value isn't getting updated – Arahasya Oct 28 '18 at 11:51
-
Read this https://stackoverflow.com/questions/52213333/how-to-update-shared-prefrences-data-when-user-updates-the-app – Arahasya Oct 28 '18 at 12:00
1 Answers
0
If you will be updating only some checkboxes change the keys for those in SharedPreferences. You will have to manually handle the upgrade. Check the version and do necessary action.
If you will be updating all..clearing all saved SharedPreferences and adding again will do the job

Arahasya
- 525
- 3
- 14