I want to map array from Firebase as a list of string in Kotlin
I have been searching for answer in may threads but they doesn't answer my question
Now I fetch whole collection and I get DocumentSnapshot. When I do
list = it["myArray"].toString()
I get string:
list = [text1, text2, text3]
How Can I convert it to list?
CodePudding user response:
You can use split() like,
val newList = list.split(',')
It will split the strings from every occurrence of ',' in it, and will return a list containing all the spliced strings.
CodePudding user response:
You can use .toList() if you want to convert them to list:
list = it["myArray"].toList()