greenDao3.0之后的使用方式:
1.新建一个android 项目在app builde.gradle下配置jar包并引用插件
apply plugin: 'org.greenrobot.greendao'
dependencies {
compile 'org.greenrobot:greendao:3.2.0'
}
2.在project下的builde.gradle下配置插件
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'org.greenrobot:greendao-gradle-plugin:3.2.0'
}
}
3.回到app 下的build.gradle配置greenDao的版本号生成类的包名
greendao{
schemaVersion 1
daoPackage 'com.ln.test.db'
targetGenDir 'src/main/java'
}
至此 配置就完成了,下来就开始生成数据库并使用
1.在项目中新建一个表字段的bean并不需要自己写get set方法在生成表的时候会自动生成。不要忘了在类名上标记@Entity注解如图:
2.选择build ——Make Project 一切顺利的话则会在gradle中配置的包名下生成
数据库。
二、greedao3.0之前的配置方式可以点这里查看
本文介绍GreenDao 3.0版本后的配置及使用流程,包括Gradle配置、数据库生成步骤等,并提供示例代码帮助理解。

1605

被折叠的 条评论
为什么被折叠?



