在我的房间应用程序中,我在 populateDatabase 函数中收到两个警告:从不使用参数“pbInfoDao”,从不使用变量“pbInfo”
任务:app:prepareLintJar 最新任务:app:generateDebugSources 任务:app:javaPreCompileDebug 任务:app:compileDebugJavaWithJavac 任务:app:compileDebugSources 任务:app:mergeDebugShaders 任务:app:compileDebugShaders 任务:app:generateDebugAssets 任务:app:mergeDebug资产
我将如何解决这些问题?
@Entity(tableName = "pbInfo_table")
data class PbInfo(@PrimaryKey
var value: Double,
var date: Int,
var details: String)
interface PbInfoDao {
@Query("SELECT * from pbInfo_table")
fun getListPbs(): LiveData<List<PbInfo>>
@Query("SELECT value, date, details FROM pbInfo_table")
fun loadPbInfo(): List<PbInfo>
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun update(vararg pbInfo: PbInfo): LongArray
@Query("DELETE FROM pbInfo_table")
suspend fun deleteAll()
}
D b
private class PbDatabaseCallback(private val scope: CoroutineScope) : RoomDatabase.Callback() {
override fun onOpen(db: SupportSQLiteDatabase) {
super.onOpen(db)
INSTANCE?.let { database ->
scope.launch {
populateDatabase(database.pbDao(), database.pbInfoDao())
}
}
}
suspend fun populateDatabase(pbDao: PbDao,pbInfoDao: PbInfoDao) {
pbDao.deleteAll()
var pb = Pb("Squat")
pbDao.insert(pb)
var pbInfo = PbInfo(122.5, 28, "I was feeling on top form today!")
ABOUTYOU
相关分类