我试图将原始字符串集复制到其他三个字符串集。存储/复制后如下图所示,如果我尝试打印内容不同。任何帮助表示感谢。
{
SharedPreferences sp = this.getSharedPreferences("SS", 0);
Set<String> s = new HashSet<String>(sp.getStringSet("DD", new HashSet<String>()));
Object[] array = s.toArray();
SharedPreferences.Editor editor = sp.edit();
editor.putStringSet("CC", s);
editor.commit();
Set<String> zz = new HashSet<String>(sp.getStringSet("ZZ", new HashSet<String>()));
zz.add(array[0].toString());
zz.add(array[1].toString());
SharedPreferences.Editor editor_zz = sp.edit();
editor_zz.putStringSet("ZZ", ZZ);
editor_zz.commit();
Set<String> hop = new HashSet<String>(sp.getStringSet("HH", new HashSet<String>()));
hop.add(array[1].toString());
hop.add(array[0].toString());
SharedPreferences.Editor editor_hop = sp.edit();
editor_hop.putStringSet("HH", hop);
editor_hop.commit();
logSet = null;
iterator = null;
logSet = new HashSet<String>(sp.getStringSet("ZZ", new HashSet<String>()));
iterator = logSet.iterator();
while (iterator.hasNext())
{
String zz = iterator.next();
Log.d("wrong string Y??","ZZList "+zz);
}
}