不使用AndroidX的依赖
1 | def room_version = "1.1.1" |
1 |
|
1 | @Database(entities = [User::class], version = 1) |
1 | @Dao |
1 | val userDao: UserDao by lazy { |
监控数据变化
使用RoomDatabase.getInvalidationTracker获取InvalidationTracker对象来监听表数据的改变。一般推荐直接在DAO方法中返回LiveData或者Observable对象。
1 | @Query("SELECT * FROM ConsumeInfo where timeStr LIKE :month ORDER BY time ASC") |
1 | private val users: MutableLiveData<List<User>> by lazy { |