Java convert ArrayList to string and back to ArrayList?

后端 未结 6 1353
一个人的身影
一个人的身影 2020-12-29 11:30

I wanted to save an ArrayList to SharedPreferences so I need to turn it into a string and back, this is what I am doing:

// Save to shared preferences
Shared         


        
6条回答
  •  醉梦人生
    2020-12-29 11:49

    Update to Dhruv Gairola's answer for Kotlin

    val gson = Gson();
    val jsonString = gson.toJson(arrayList) 
    

提交回复
热议问题