我有Advertiser
课程,在Kotlin中扩展SugarRecord
:
class Advertiser : SugarRecord<Advertiser> {
var number: String? = null
var name: String? = null
constructor() {}
constructor(number: String, name: String) {
this.number = number
this.name = name
}
}
当我尝试通过Java查找记录时,它可以正常工作:
Advertiser advertiser = Advertiser.find(Advertiser.class, "number = ?", "123123").get(0);
但是当我将此代码转换为Kotlin时,我遇到了问题:
如何在Kotlin中执行查找?
答案 0 :(得分:4)
你应该这样称呼它
SugarRecord.find(Advertiser::class.java, "number = ?", "123123").get(0)
希望它有所帮助!