android SharedPreferences putStringSet 顺序/排序

android SharedPreferences putStringSet order/sort(android SharedPreferences putStringSet 顺序/排序)
本文介绍了android SharedPreferences putStringSet 顺序/排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试保存/恢复一组字符串,除一件事外,一切正常.当我创建我的字符串时,我放了:

I try to save/restore a set of string and all is working except one thing. When i create my strings i put :

Set<String> set = new HashSet<String>();
for(int i=0; i<toggles.size();i++){
   set.add(toggles.get(i).serialise());                 
}

顺序例如是蓝牙"应用程序"数据".当我回来的时候:

Order is for example "blutooth" "application" "data". When i get back set :

Set<String> set = prefs.getStringSet(key, new HashSet<String>());
for (String toggle : set){
    Toggle t = new Toggle();
    t.deserialize(toggle);
    toggles.add(t); 
}

我得到应用程序"蓝牙"数据",它们是按名称排序的,我不想要这个.我想获得与我保存的相同的订单.任何人都可以帮助我吗?

I get "application" "bluetooth" "data" they are sort by name and i don't want this. I want to get same order i have save. Anyone can help me ?

推荐答案

这是不可能的.集合是无序的集合.

This is not possible. Sets are unordered collections.

这篇关于android SharedPreferences putStringSet 顺序/排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)
Android + coreLibraryDesugaring: which Java 11 APIs can I expect to work?(Android+core LibraryDesugering:我可以期待哪些Java 11API能够工作?)
How to render something in an if statement React Native(如何在If语句中呈现某些内容Reaction Native)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Using Firebase Firestore in offline only mode(在仅脱机模式下使用Firebase FiRestore)
Crash on Google Play Pre-Launch Report: java.lang.NoSuchMethodError(Google Play发布前崩溃报告:java.lang.NoSuchMethodError)