如何在Android中将HashMap对象保存到SharedPreferences中? 最佳答案 我使用Gson将HashMap转换为String然后保存到SharedPrefsprivatevoidhashmaptest(){//createtesthashmapHashMaptestHashMap=newHashMap();testHashMap.put("key1","value1");testHashMap.put("key2","value2");//converttostringusinggsonGsongson=new