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
Update to Dhruv Gairola's answer for Kotlin
val gson = Gson(); val jsonString = gson.toJson(arrayList)