java - How to keep a users selection even after they close the app? Android -
so @ moment user select colour, shape , time. when app first starts there default each. want happen keep users selection 3 of these after close app while runs in background.
if need me post ask away. thanks.
after writing out problem was, it's not they're not being saved it's fact selections being saved not being displayed properly. i.e border or dropdown menu results it's default value instead of users selection.
so values being saved(my bad) app overwrites these saves , doesn't use border or beings dropdown menu it's default value.
circularimageview = (circularimageview)findviewbyid(r.id.activity_main_silver_color_button); circularimageview.setbordercolor(getresources().getcolor(r.color.unselected_border)); circularimageview = (circularimageview)findviewbyid(v.getid()); circularimageview.setbordercolor(getresources().getcolor(r.color.selected_border));
these work independent of each other when border selected, if color selected becomes unselected border. happens if "selected_border" state never saved.
public static void savelockscreenduration(context context, int duration){ getstoredpreferences(context).edit().putint(selected_duration, duration).apply(); public static int getlockscreenduration(context context){ return getstoredpreferences(context) .getint(selected_duration, default_duration); }
this prefereces stored. default_duration , selected_duration in class called constants.
upon selection can store selected values in shared preferences. , upon launching again can check if values null or not. , display accordingly. read how use shared preferences here.
Comments
Post a Comment