I am assigning an arraylist to another, also storing it in SharedPreferences. Problem is that while fetching the arraylist from SharedPreferences. the order of arraylist is different i.e. values stored on indexes are different in the fetched arraylist .
I am using the following code for storing:
Here, I am qarrayoff
arraylist to list1
.
while printing elements of list1
it is in different order as in qarrayoff
ArrayList<String> list1 = new ArrayList<String>();
list1.addAll(qarrayoff);// fetch the data
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
SharedPreferences.Editor edit = prefs.edit();
edit.putStringSet("SAVEDATA", new HashSet<String>(list1));
edit.commit();
I want the same order i.e. same sequence of elements in both arraylist. How to achieve it?