greenDao的使用步骤:
第一步: 在项目的.gradle文件里面添加
buildscript { repositories { mavenCentral() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.3.0' classpath 'org.greenrobot:greendao-gradle-plugin:3.0.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } }主要如下图:
第二步:在moddle的.gradle文件里面添加
apply plugin: 'org.greenrobot.greendao'
greendao { schemaVersion 1 daoPackage 'com.example.john.greendaodemo.gen' targetGenDir 'src/main/java' }
依赖里面添加
compile 'org.greenrobot:greendao:3.0.1' compile 'org.greenrobot:greendao-generator:3.0.0'
如图:
第三步: 添加Bean类,用User举例子 , 一定要记得注解@Entity
@Entity public class User { @Id(autoincrement = true)