Skip to content Skip to sidebar Skip to footer

Can I Get Data From Room Query Like In Pair?

I know that I can do that by using data class but I want to achieve Like this // This is My Query @Query('SELECT loan_amount,adv_interest_amount FROM new_pledge_receive WHERE

Solution 1:

Pair class has 2 properties: first and second. Try to set the name of the selected columns to fit these names.

Something like: SELECT my_custom_field as first, my_another_field as second FROM...

Solution 2:

As they mention on the official website

For SELECT queries, Room will infer the result contents from the method's return type and generate the code that will automatically convert the query result into the method's return type. For single result queries, the return type can be any java object. For queries that return multiple values, you can use List or Array. In addition to these, any query may return Cursor or any query result can be wrapped in a LiveData.

Post a Comment for "Can I Get Data From Room Query Like In Pair?"