As the previous two answers mention, a HashSet doesn't guarantee preserving order.
One possible solution is to serialize the ArrayList into a String first, save it using putString()
, and then load it using getString()
and deserialize it.
Check out the second half of this answer to see how to do that: Save ArrayList to SharedPreferences