日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Android >内容正文

Android

android多条件查询数据,Android GreenDao 条件查询问题

發布時間:2024/1/23 Android 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android多条件查询数据,Android GreenDao 条件查询问题 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

使用GreenDao保存了全國城市的屬性(名字,代碼,省份等等),保存可以成功,無條件查詢全部數據時可以成功:

private List queryCitiesInfo(){

List cityInfos = mCityQUery.list();

for (int i = 0; i < cityInfos.size(); i++) {

Log.d(TAG,"所有的城市CountryEn"+cityInfos.get(i).getCountryEn());

}

return cityInfos;

}

但是使用條件查詢,時數據為0,不知道哪里出錯了,對了下屬性,沒知道原因:

//這個方法查詢的數據為0

private void queryCitiesByLeader(){

mCityInfoDao = nDaoSession.getCityInfoDao();

mCityQUery = mCityInfoDao.queryBuilder().orderAsc(CityInfoDao.Properties.Id).build();

List cityInfos = mCityInfoDao.queryBuilder().where(CityInfoDao.Properties.CountryEn.eq("China")).orderAsc(CityInfoDao.Properties.Id).list();

for (int i = 0; i < cityInfos.size(); i++) {

Log.d(TAG,"條件查詢城市名稱" + cityInfos.get(i).getCityEn());

}

}

@Entity

public class CityInfo {

@Id

private Long id;

private String cityEn;

private String cityZh;

private String countryCode;

private String countryEn;

private String countryZh;

private String provinceEn;

private String provinceZh;

private String leaderEn;

private String leaderZh;

private String lat;

private String lon;

@Generated(hash = 69148619)

public CityInfo(Long id, String cityEn, String cityZh, String countryCode,

String countryEn, String countryZh, String provinceEn,

String provinceZh, String leaderEn, String leaderZh, String lat,

String lon) {

this.id = id;

this.cityEn = cityEn;

this.cityZh = cityZh;

this.countryCode = countryCode;

this.countryEn = countryEn;

this.countryZh = countryZh;

this.provinceEn = provinceEn;

this.provinceZh = provinceZh;

this.leaderEn = leaderEn;

this.leaderZh = leaderZh;

this.lat = lat;

this.lon = lon;

}

@Generated(hash = 300452937)

public CityInfo() {

}

public Long getId() {

return this.id;

}

public void setId(Long id) {

this.id = id;

}

public String getCityEn() {

return this.cityEn;

}

public void setCityEn(String cityEn) {

this.cityEn = cityEn;

}

public String getCityZh() {

return this.cityZh;

}

public void setCityZh(String cityZh) {

this.cityZh = cityZh;

}

public String getCountryCode() {

return this.countryCode;

}

public void setCountryCode(String countryCode) {

this.countryCode = countryCode;

}

public String getCountryEn() {

return this.countryEn;

}

public void setCountryEn(String countryEn) {

this.countryEn = countryEn;

}

public String getCountryZh() {

return this.countryZh;

}

public void setCountryZh(String countryZh) {

this.countryZh = countryZh;

}

public String getProvinceEn() {

return this.provinceEn;

}

public void setProvinceEn(String provinceEn) {

this.provinceEn = provinceEn;

}

public String getProvinceZh() {

return this.provinceZh;

}

public void setProvinceZh(String provinceZh) {

this.provinceZh = provinceZh;

}

public String getLeaderEn() {

return this.leaderEn;

}

public void setLeaderEn(String leaderEn) {

this.leaderEn = leaderEn;

}

public String getLeaderZh() {

return this.leaderZh;

}

public void setLeaderZh(String leaderZh) {

this.leaderZh = leaderZh;

}

public String getLat() {

return this.lat;

}

public void setLat(String lat) {

this.lat = lat;

}

public String getLon() {

return this.lon;

}

public void setLon(String lon) {

this.lon = lon;

}

}

下面是部分日志,打印出CountryEn:

第一次用GreenDao, 找了很久沒發現問題,望解答,感謝。

總結

以上是生活随笔為你收集整理的android多条件查询数据,Android GreenDao 条件查询问题的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。