GreenDAO使用手册
来源:互联网 发布:批量生成二维码软件 编辑:程序博客网 时间:2024/06/06 04:39
首页:http://greendao-orm.com/
GreenDAO的使用很像Java中常用的Hibernate框架
Pre-generated code and creating the table
Using the DaoMaster class you can aquire a convenience SQLiteOpenHelper:
new DaoMaster.DevOpenHelper(this, "notes-db", null)
Inserting and deleting notes
In the onCreate method we prepare a DAO object:
daoMaster = new DaoMaster(db);
daoSession = daoMaster.newSession();
noteDao = daoSession.getNoteDao();
Now have a look at the addNote method, how you insert a new note in the database:Note note = new Note(null, noteText, comment, new Date());
noteDao.insert(note);
Log.d("DaoExample", "Inserted new note, ID: " + note.getId());
Deleting a note is also straight forward; have a look at the onListItemClick method:
noteDao.deleteByKey(id);
It contains a single class containing the data model definition in code:
Schema schema = new Schema(1, "de.greenrobot.daoexample");
Entity note= schema.addEntity("Note");
note.addIdProperty();
note.addStringProperty("text").notNull();
note.addStringProperty("comment");
note.addDateProperty("date");
new DaoGenerator().generateAll("../DaoExample/src-gen", schema);
0 0
- GreenDAO使用手册
- greenDao
- greenDAO
- greenDAO
- greenDAO
- GreenDao
- GreenDAO
- Greendao
- greenDAO
- GreenDao
- GreenDao
- GreenDao
- GreenDAO
- GreenDAO
- GreenDao
- GreenDao
- greenDAO
- GreenDAO
- Android 分辨率 与计量单位
- 70 Android service 进程间通信 Messenger(二)
- 一些喜欢的话
- Qt之遍历文件夹(经典详解)
- httpclient4文档及下载地址
- GreenDAO使用手册
- 临界区、互斥量、信号量、事件的区别
- Qt之自定义菜单(按钮菜单)
- php 处理中文 mb系列函数
- netbeans xdebug
- Acronis 2014年度存储备份市场预测
- 云趋势:SaaS走向全球IaaS竞争激烈PaaS前景堪忧
- 部署强命名程序集到GAC
- 图像方面博客