Array of strings in SharedPreferences

前端 未结 4 1363
感动是毒
感动是毒 2020-12-06 13:27

I wanna know whether is it possible to store array of string in the SharedPreferences. In my application i want , set of names to be stored

4条回答
  •  长情又很酷
    2020-12-06 13:27

    You can store set of String using SharedPreferences in API Level 11 and higher. See getStringSet() and putStringSet()ю

    In API Level prior to 11 you can use some kind of hack. For example, if you need to store string array under key "stringArray", you can save each string from array using putString and keys "stringArray.1", "stringArray.2", so on.

提交回复
热议问题