I need to read a Map of 6000 pairs in Kotlin

Viewed 34

I was creating a Kotlin program for Android that reads some data from a Map. By giving the Key I get the Value. In the attached code there is the class that contains the data list. Everything works perfectly with this test data. The problem is that the real Map contains 6000 pairs of data and the compiler crashes. Is there a way to read external XML in Android? I tried with a database but given my poor programming skills I couldn't.

class Tavole(var codice: String) {

    var lettere = ""

    val oracolo = linkedMapOf(
        "19911" to "simostrera",
        "19912" to "finchetiavvam",
        "91931" to "tedura",
        "91932" to "maimpura",
        "99121" to "vertelasor",
        "99122" to "painsenofiam"
    )

    fun leggiMap(codice: String):(String) {
        for (key in oracolo.keys) {
            if (key==codice) {lettere = oracolo.getValue(key).toString()}
        }
     return lettere
    }

}
0 Answers
Related