greenDao使用方法二

2021-08-01 15:08:10 字數 1355 閱讀 9469

回看上篇文章,發現只簡述了怎麼配置greendao的生成工程,而使用的部分內容忘了寫了,罪過。。 在這裡補上吧。。

執行結束,會在你指定的路徑下生成相應的類檔案

daomaster與daosession是必定生成的,負責對資料庫表的操作,而customer和customerdao是在你新增了對應的表結構後生成。

到這裡,基本就可以對資料庫進行增刪改查的操作了,但為了操作的方便,可以自行新增乙個類,來處理對資料庫的各種操作。

public

class dbhelper

// 單例模式,dbhelper只初始化一次

public

static dbhelper getinstance(context context)

minstance.maccountdao = minstance.mdaosession.getaccountdao();

}return minstance;

}// 刪除account表

public

void

droprecordtable()

// 建立表

以上就完成了在專案中配置,以及使用greendao資料庫的方法。

greendao3 2 0使用方法(超詳細)

greendao是greenrobot組織出品的一款操作android自帶資料庫sqlite的框架 使用環境 as版本3.12 低版本配置greendao方法有所不同 1.配置 module的gradle檔案中 新增外掛程式 plugin org.greenrobot.greendao androi...

GreenDao 使用教程 二

greendao的插入 插入的方式有很多 1 daosession getnotedao insert note 插入note 如果note指定主鍵與表中已經存在了,就會發生異常 android.database.sqlite.sqliteconstraintexception unique con...

cx Oracle使用方法二

技術手冊 cx oracle使用方法 正確安裝好cx oracle之後,要使用它來連線到oracle資料庫進行操作,具體應該分3步走 import cx oracle 匯入模組 db cx oracle.connect hr hrpwd localhost 1521 xe 建立連線,3 個引數分開寫...