I put the String in SharedPreferences like this
SharedPreferences preferences = getActivity().getSharedPreferences("Music_playlist", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putString(Song_name, Song_name);
editor.commit();
and when i try to retrieve Strings from SharedPreferences it doesn't Maintain the same order as it is stored in sharedPreferences
SharedPreferences prefs = getActivity().getSharedPreferences("Music_playlist", Context.MODE_PRIVATE);
Map<String,?> keys = prefs.getAll();
if(keys!=null) {
for (Map.Entry<String, ?> entry : keys.entrySet()) {
Log.d("data ADDED",(String)entry.getValue());
PLAYLIST.add((String)entry.getValue());
}
}
how should i store Strings in SharedPreferences and Maintain the order while getting the Strings from it