Android的GreenDao笔记

ORM概念

对象关系映射(英语:Object Relational Mapping,简称ORM,或O/RM,或O/R mapping),是一种程序设计技术,用于实现面向对象编程语言里不同类型系统的数据之间的转换。
——维基百科
俗称把数据库查询的结果转为对象(就是这么简单

配置

https://github.com/greenrobot/greenDAO
官网写的很清楚了

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// In your root build.gradle file:
buildscript {
repositories {
jcenter()
mavenCentral() // add repository
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.1'
classpath 'org.greenrobot:greendao-gradle-plugin:3.2.2' // add plugin
}
}
// In your app projects build.gradle file:
apply plugin: 'com.android.application'
apply plugin: 'org.greenrobot.greendao' // apply plugin
android {
...
....
greendao{
schemaVersion 1 //数据库版本号 每次改动数据库结构要更改
targetGenDir 'src/main/java'///设置DaoMaster 、DaoSession、Dao目录
//设置DaoMaster 、DaoSession、Dao包名 非必填
// daoPackage 'com.qhn.bhne.footprinting.db'
//设置生成单元测试目录
// targetGenDirTest
//设置自动生成单元测试用例
// generateTests
}
}
dependencies {
implementation 'org.greenrobot:greendao:3.2.2' // add library
}

Powered By Valine
v1.5.2