Reading DB SQLite Android Studio (Kotlin)

0

Next, I have a problem reading a data from the database, using the following method:

ButIhavethislittleproblemonline68.WhereareyoutalkingaboutexpectingavalueoftypeTipo()andI'mpassingString,onlywhenIputreferencingmyTipo()classlikethis:

  

t.type=result.getString(result.getColumnIndex(COL_TIPO))Type

Hedoesnotacceptit.

Thisismyclasstype:

enumclassTipo{RECEITA{overridefuntoString():String{return"RECEITA"
        }
    },
    DESPESA
    {
        override fun toString(): String
        {
            return "DESPESA"
        }
    }

}

If someone has an idea, or a better method to read.

This is my Transaction model in which I have my attributes:

class Transacao(var valor: BigDecimal,
                var categoria: String = "Indefinida",
                var tipo: Tipo,
                var data: Calendar = Calendar.getInstance()) {

}
    
asked by anonymous 18.11.2018 / 19:16

1 answer

0

I was able to solve it, I just needed to declare Tipo after equal and receive a valueOf of type string, being as follows:

t.tipo = Tipo.valueOf(result.getString(result.getColumnIndex(COL_TIPO)).toString())
    
18.11.2018 / 19:42