I am using Room persistence library in my to access DB data.
In my dao class i write queries as
@Query("SELECT id, uniqueId, number, user_id, first_name, last_name,
image FROM CONTACTS WHERE status != stts")
abstract fun allContacts(stts: Int): DataSource.Factory<Int, Contact>
This is fine . But what if i have to compare status to some constant value , like status != Constant.STATUS_FAILED
Here val STATUS_FAILED = 5 defined in Constant File.
How do i use it in query. I know i can just pass it in the allContacts method as parameter and use like status != :stts . But i do not want that. Is there any way to use it directly like status != Constant.STATUS_FAILED.
I do not see any example on https://developer.android.com/training/data-storage/room/accessing-data
You must add this : in @Query
@Query("Select * from Workout where nameTypeTraining= :nameTypeTraining")
Try it like this
@Query("SELECT id, uniqueId, number, user_id, first_name, last_name,
image FROM CONTACTS WHERE status != " + Constant.STATUS_FAILED)
abstract fun allContacts(): DataSource.Factory<Int, Contact>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With