In my application, I use this class as a model:
class ExpenseItem (val concept: String, val amount: String, val months: List<String>, val type: Type, val cards_image: Int, val payDay: Int, val notes: String) {
enum class Type {RECURRENT, VARIABLE}
}
And with this model, I create a mutable list
var generalExpensesList: MutableList<ExpenseItem> = mutableListOf()
and I add items
val currentExpense = ExpenseItem(
concept,
amount,
listOfMonths,
enumtype,
card_image_number,
payday.toInt(),
notes
)
generalExpensesList.add(currentExpense)
As you can see, one of the model fields is also a String type list, in case it was important
Well, my intention is to convert this list to String, save it as a sharedpreference, and then create a new list using that String retrieved from the sharedpreference.
To convert the list to String I can use toString or joinToString, both give me an optimal result.
I have the problem when I want to create a new list from the String.
I can do it with lists of type List<String>, but never with lists of type List<ExpenseItem>
Can someone help me with this?
[one, two]. Do you want to convert this content form String to List<String>?