我像这样将字符串放在 SharedPreferences 中
SharedPreferences preferences = getActivity().getSharedPreferences("Music_playlist", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putString(Song_name, Song_name);
editor.commit();
当我尝试从 SharedPreferences 检索字符串时,它不会保持与存储在 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());
}
}
我应该如何在 SharedPreferences 中存储字符串并在从中获取字符串时保持顺序