I\'m trying to make a @Query function in my @Dao interface which has a boolean parameter, isAsc to determine the order:
@Query
@Dao
isAsc
@Q
Use CASE Expression for SQLite to achieve this in Room DAO,
CASE Expression
@Query("SELECT * FROM Persons ORDER BY CASE WHEN :isAsc = 1 THEN first_name END ASC, CASE WHEN :isAsc = 0 THEN first_name END DESC") List getPersonsAlphabetically(boolean isAsc);