HashSet keySet = preferences.getStringSet("key", keySet);这一步很关键,否则set集合不能追加数据。if(keySet!=null){keySet =newHashSet(keySet);}keySet.add(key);之后在进行添加keyEditor.putStringSet("key", keySet);keyEditor.commit();