工程目录
带//
buildscript {
repositories {
google()
jcenter()
mavenCentral() // add repository
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'org.greenrobot:greendao-gradle-plugin:3.2.2' // add plugin
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
app
apply plugin: 'org.greenrobot.greendao' // apply plugin
compile 'org.greenrobot:greendao:3.2.2' // add library
// This is only needed if you want to use encrypted databases
compile 'net.zetetic:android-database-sqlcipher:3.5.6'//加密库依赖(可选项)
APPlication
private DaoSession daoSession;
@Override
public void onCreate() {
super.onCreate();
DaoMaster.DevOpenHelper helper=new DaoMaster.DevOpenHelper(this,"user.db");
DaoMaster daoMaster=new DaoMaster(helper.getWritableDatabase());
daoSession=daoMaster.newSession();
}
public DaoSession getDaoSession(){
return daoSession;
}
@Entity
public class User {
@Id
private Long id;
private String name;
}
greendao
最新推荐文章于 2022-03-25 11:57:03 发布