Greendao 3.2.0查询几个关键写法

loadAll():查询所有记录
load(Long key):根据主键查询一条记录
queryBuilder().list():返回:List列表
queryBuilder().where(UserDao.Properties.Name.eq("")).list():返回:List列表
queryRaw(String where,String selectionArg):返回:List列表

查询表中某个字段是否有了一样的值,比如表中的keyword或者日期等等,有的话就不添加
对应这个实体类


import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Generated;

@Entity
public class AllSearchHistoryWordDB {
    @Id
    private Long id;

    private String keyword;
    private String url;
    private String Date;
    @Generated(hash = 797301940)
    public AllSearchHistoryWordDB(Long id, String keyword, String url,
            String Date) {
        this.id = id;
        this.keyword = keyword;
        this.url = url;
        this.Date = Date;
    }
    @Generated(hash = 408656757)
    public AllSearchHistoryWordDB() {
    }
    public Long getId() {
        return this.id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public String getKeyword() {
        return this.keyword;
    }
    public void setKeyword(String keyword) {
        this.keyword = keyword;
    }
    public String getUrl() {
        return this.url;
    }
    public void setUrl(String url) {
        this.url = url;
    }
    public String getDate() {
        return this.Date;
    }
    public void setDate(String Date) {
        this.Date = Date;
    }



}

    //是否搜索字重复
    public boolean isAllSearchWordDulplicated(String keyword){
        List dulplicatedList = GreendaoUtil.getInstance().getmDaoSession().getAllSearchHistoryWordDBDao().queryBuilder().where(AllSearchHistoryWordDBDao.Properties.Keyword.eq
                (keyword)).list();
        if (dulplicatedList.size()>0){
            return true;
        }else {
            return false;
        }
    }

你可能感兴趣的:(greendao,sqlite,Greendao,Android)