How to dynamically query the room database at runtime?

后端 未结 8 1862
青春惊慌失措
青春惊慌失措 2020-11-30 05:42

The problem

Is it possible construct a query at runtime?


Use case

@Query(\"SELECT * FROM playlist \" +
        \"WHERE play         


        
8条回答
  •  日久生厌
    2020-11-30 06:00

    Make it more simple. I'll show you example using where clause using two variable. Do it like this:

      @Query("SELECT * FROM Student WHERE stdName1= :myname AND stdId1=:myid")
    List fetchAllData(String myname,int myid);
    

    stdName1 and stdId1 are column names

提交回复
热议问题