So I am using room database to persist users locally, now users have this entity class:
@Entity
public class Users{
public string name;
public string email;
@PrimaryKey
public string id;
......
}
I retrieve all these users with a DAO that looks like this:
@DAO
public interface UsersDAO{
@Query("select * from Users")
public List<Users> getAllUsers();
}
The above DAO will read all users in the order they were added to the database.
Question:
Is it possible to query users by the name
field in Users
entity alphabetically?
Thanks.
使用ORDER BY
关键字。
"select * from Users ORDER BY name"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.