0

I am trying to sort my data by ascending and descending order using room database. So I need to pass those parameter to the DAO.

This is my code:

@Query("SELECT * FROM DEVICES_TABLE ORDER BY :sortQuery")
fun sortDatabase(sortQuery: String): Flow<List<DeviceData>>

But when I pass title DESC as sortquery (title is column name), the query becomes:

SELECT * 
FROM DEVICES_TABLE 
ORDER BY 'title ASC'

I need to remove those single quotes from query for achieving the results. I need to sort with title, price, type etc. both ascending and descending. How can I do that?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
sony
  • 77
  • 1
  • 12

0 Answers0