【发布时间】:2020-09-17 09:49:56
【问题描述】:
现在我在我的 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>>。
哪种方法更可取?
【问题讨论】:
标签: android kotlin android-room rx-java2 android-livedata