javaandroidkotlinsugarorm

Find Sugar ORM Record in Kotlin


I have Advertiser class which extends SugarRecord in Kotlin:

class Advertiser : SugarRecord<Advertiser> {
    var number: String? = null
    var name: String? = null

    constructor() {}

    constructor(number: String, name: String) {
        this.number = number
        this.name = name
    }
}

when I try to find records by Java it works fine:

   Advertiser advertiser =  Advertiser.find(Advertiser.class, "number = ?", "123123").get(0);

but when I convert this code to Kotlin I face problem:

enter image description here

how can I perform find in Kotlin?


Solution

  • You should call it this way

    SugarRecord.find(Advertiser::class.java, "number = ?", "123123").get(0)