How can I store a HashMap in android using shared preferences?

后端 未结 3 1293
渐次进展
渐次进展 2020-12-18 12:56

I have created a HashMap in the following way:

HashMap buttons = new HashMap();

I need this to rem

3条回答
  •  暖寄归人
    2020-12-18 13:10

    There is no support for any HashMap in SharedPreferences. You can treat a whole SharedPreferences as being a bit like a HashMap, but it is not a HashMap, and you cannot store a HashMap in an individual preference.

    You are welcome to convert your HashMap into a String that could be stored in a SharedPreferences value, such as by converting it into JSON.

提交回复
热议问题