/** * * Store a set in SharedPreferences, using the built-in putStringSet method * if available and falling back to a comma separated String if not. * * * Note that this is a simple approach that won't work if the values in the * set contain commas. * * @param editor the editor to store the set in. * @param key the key for the preference. * @param value the value to store with the key. */ @TargetApi(Build.VERSION_CODES.HONEYCOMB) public static void putStringSet(SharedPreferences.Editor editor, String key, Set<String> value) { if(supportsStringSet()) { editor.putStringSet(key, value); } else { editor.putString(key, Joiner.on(",").join(value)); } } }
String key, Set<String> defaultValue) { Set<String> result = defaultValue; if(supportsStringSet()) { result = preferences.getStringSet(key, defaultValue); } else {