MVVM Recyclerview Livedata Room SearchView

前端 未结 1 1206
难免孤独
难免孤独 2021-01-17 08:17

I am making database app using room, mvvm, livedata . I have Prepopulated it with some data. Now i have two options either i am going to show that prep

相关标签:
1条回答
  • 2021-01-17 08:39

    Please change your @Dao class like this

    @Dao
    abstract class SearchDao : BaseDao<SearchPojo> {
    
        @Query("Select * from SearchPojo")
        abstract fun allSearch(): LiveData<List<SearchPojo>>
    
        @Query("Select * from SearchPojo where userName GLOB '*' || :userNameSearch|| '*'")
        abstract fun searchViaID(userNameSearch: String) : LiveData<List<SearchPojo>>
    
        @Insert
        abstract override fun insert(searchPojo: SearchPojo)
    
    }
    
    0 讨论(0)
提交回复
热议问题