我使用了Room持久化库来存储联系人信息。
我想通过姓和名来检索联系人。
问题在于没有姓和名的联系人(null)会出现在列表的顶部。如何查询以使它们出现在列表底部?
以下是我的查询语句:
select * from CacheContact order by lastName asc,firstName asc LIMIT :count OFFSET :offset
CacheContact 对象:
@Entity
public class CacheContact {
private String expireDate;
@PrimaryKey
private long id;
private String firstName;
private long userId;
private String lastName;
private Boolean blocked;
private long creationDate;
private String profileImage;
@Embedded
private LinkedUser linkedUser;
private String cellphoneNumber;
private String email;
private String uniqueId;
private long notSeenDuration;
private boolean hasUser;
完整的DAO方法:
@Query("select * from CacheContact order by lastName asc,firstName asc LIMIT :count OFFSET :offset")
List<CacheContact> getContacts(Integer count, Long offset);
or
部分。 - Nongthonbam Tonthoi