我应该在DAO中使用哪种方法来使用Room操作数据库中的数据?

问题描述

现在,我在DAO中使用以下代码:

@Dao
interface NotesDao {

    @Query("SELECT * FROM Notes")
    fun getAllNotes(): List<Notes?>?

    @Query("SELECT * FROM Notes WHERE not hidden AND not grouped")
    fun getNotes(): List<Notes?>?

    @Query("SELECT * FROM Notes WHERE id = :id")
    fun getById(id: Long): Notes?

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun insert(notes: Notes?)

    @Update
    fun update(notes: Notes?)

    @Delete
    fun delete(notes: Notes?)
}

但是在许多教程中,我看到的是Flowable<List<Notes>>而不是List<Notes>LiveData<List<Notes>>。 哪种方法更好?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)