1. 程式人生 > >android中ORM(物件關係對映)資料庫greenDAO的使用

android中ORM(物件關係對映)資料庫greenDAO的使用

    /**
     * 查詢儲存的工作資訊
     */
private void queryOrganizationInfo() {
        DaoSession daoSession = ((MyApplication) getApplication()).getDaoSession();
mOrganizationInfoDao = daoSession.getOrganizationInfoDao();
//        List<OrganizationInfo> organizationInfoList = mOrganizationInfoDao.queryBuilder().build().list();
List<OrganizationInfo> organizationInfoList = mOrganizationInfoDao.queryBuilder().where(OrganizationInfoDao.Properties.MobileNum.eq(DataWareHouse.getMobileNum())).orderAsc(OrganizationInfoDao.Properties.Id).build().list();
        if (organizationInfoList.size() > 0) {
            int i = organizationInfoList.size() - 1
;
mEtOrganization.setText(organizationInfoList.get(i).getOrganization());//單位名稱
mEtOrganizationPhone.setText(organizationInfoList.get(i).getOrganizationPhone());//單位號碼
organizationProvince = organizationInfoList.get(i).getOrganizationProvince();//省
organizationCity = organizationInfoList.get(i).getOrganizationCity();
//市
organizationArea = organizationInfoList.get(i).getOrganizationArea();//區
mSelectJobAddress.setText(organizationProvince organizationCity organizationArea);
mEtDetailOrganizationAddress.setText(organizationInfoList.get(i).getDetailOrganizationAddress());//詳細地址
mSelectWorktime.setText(organizationInfoList.get(i).getWorktime());
mEtMonthlyIncome.setText(organizationInfoList.get(i).getMonthlyIncome());
}
    }