Android saves list state with multipleChoice

I have a list containing some multipleChoice-enabled values ​​in my XML file. I want to be able to save what was verified by the user when exiting the application, and then re-verify what they selected when opening again. My code works for a radio group, but I can't get it to work for that.

EDIT: Got this work, using some to trick the loops at the end.

+4
source share
2 answers

You can use SharedPreferences to continue your selection.

+1
source

as @BGS wrote, SharedPreference will solve your problem. Check this post: MultiChoice Preference Widget for Android .

Here, the flag values ​​are stored in the [special-separator] line and passed to the caller as a String array containing the selected values.

I use this approach and it has been working fine so far.

+1
source

Source: https://habr.com/ru/post/1338322/


All Articles