我正在使用Realm。这是我的RealmObject类
public class Transactions extends RealmObject implements Serializable {
@Index
@PrimaryKey
private long id;
private String amount = "";
private String transactionStatus = "";
private String signature = "";
private String dateTime = "";
private String paymentType = "";
private String companyId = "";
private String company = "";
private String companyIdentification = "";
private String address = "";
private String serialNumber = "";
private String terminalId = "";
private String additionalText = "";
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getTransactionStatus() {
return transactionStatus;
}
public void setTransactionStatus(String transactionStatus) {
this.transactionStatus = transactionStatus;
}
public String getSignature() {
return signature;
}
public void setSignature(String signature) {
this.signature = signature;
}
public String getDateTime() {
return dateTime;
}
public void setDateTime(String dateTime) {
this.dateTime = dateTime;
}
public String getPaymentType() {
return paymentType;
}
public void setPaymentType(String paymentType) {
this.paymentType = paymentType;
}
public String getAmount() {
return amount;
}
public void setAmount(String amount) {
this.amount = amount;
}
public String getCompanyId() {
return companyId;
}
public void setCompanyId(String companyId) {
this.companyId = companyId;
}
public String getCompany() {
return company;
}
public void setCompany(String company) {
this.company = company;
}
public String getCompanyIdentification() {
return companyIdentification;
}
public void setCompanyIdentification(String companyIdentification) {
this.companyIdentification = companyIdentification;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getSerialNumber() {
return serialNumber;
}
public void setSerialNumber(String serialNumber) {
this.serialNumber = serialNumber;
}
public String getTerminalId() {
return terminalId;
}
public void setTerminalId(String terminalId) {
this.terminalId = terminalId;
}
public String getAdditionalText() {
return additionalText;
}
public void setAdditionalText(String additionalText) {
this.additionalText = additionalText;
}
} 我的目标是选择具有两个条件的项目 1)金额在1.00 --- 10.00
之间2)日期为1.2.2018 - 12.2.2018(例如)
我尝试选择数量这样的数据,但结果是真实的
final RealmResults<Transactions> transactions = realm.where(Transactions.class)
.between("amount", 0, 10)
.findAllSorted("id", Sort.DESCENDING);
如何根据我的条件选择项目(选择金额或日期) 谢谢大家
答案 0 :(得分:0)
您的查询无效,因为您的数据类型错误。
private String amount
private String dateTime
应该是
private int amount;
private Date dateTime;