Search code examples
javaandroidandroid-multiselectlistpreference

Removing array tags on multilistpreference summary


I have a MultiSelectListPreference() set up. My issue isn't displaying the checked value as summary but removing tags of the array when a value is checked.

Summary of the preference are like this using the below code:

[Adam, Atom, Berry]

But my desired result should be like this when the correct entry is checked as summary:

Adam, Atom, Berry

Here is what I have so far that gives me the array tags "[ ]"

SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
 Set<String> selections = preferences.getStringSet("rssfeeds", null);
 String[] selected= selections.toArray(new String[] {});
ssid.getSummary(selected.toString());

Any pointers achieving this??


Solution

  • For those that will encounter this in the future, I solved this by looping through the selections then using a StringBuilder() to store each checked box input from the user. I however removed the array tags by just doing replace(old char, new char) where the old char is the tag and the new char is just an empty space "".