I have a Kotlin data class
data class Item (val content: String) {}
In my app I use an myData: ArrayList<Item>
.
To provide persistant storage the app writes this list to a file everytime it is changed:
configFile.writeText(myData.toString())
At startup it reads the file and with configfile.readFile()
. The returned string look like this:
[Item(content=Click #1), Item(content=Click #2)]
How can I create the arraylist from this string?