I'm trying to save and retrieve an ArrayList as shared preference.
I have three items in my ArrayList named arra ,but when I try to add the values in Set in the set.addAll(arr), only two items get added.
Are there any corrections that can be one in the following code so I can save the arraylist correctly as shared preferences.
 SharedPreferences prefs = this.getSharedPreferences(filename,Context.MODE_PRIVATE);
                    Set<String> set = prefs.getStringSet(filename, null);
                    arra = new ArrayList<String>();
                    for (String str : set)
                       arra.add(str);
Saving of ArrayList
 SharedPreferences prefs=this.getSharedPreferences(filename,Context.MODE_PRIVATE);
        SharedPreferences.Editor edit=prefs.edit();
        Set<String> set = new HashSet<String>();
        set.addAll(arr);
        edit.putStringSet(filename, set);
        edit.commit();
 
     
    