greenDAO3.1框架(四)添加全局初始化及基本使用
全局初始化greenDAO设置
1 | public class UserGlobalApp extends Application{ |
使用
添加数据,查询数据
1 | UserGlobalApp.getApplication().getDaoSession().getTrackPointDao().insert(new TrackPoint((long) 10,System.currentTimeMillis(),10.01,10.02,1)); |
生成的dao目录配置(非必须)
1 | //------------greenDAO数据库配置----------- |
问题
数据库加密问题
在全局配置中如果要加密,要设置为true,但是设置为ture会报错
1 | public static final boolean ENCRYPTED = false; //改为true需要加入包compile |
解决:因为没有加密包,需要添加依赖
1 | compile 'net.zetetic:android-database-sqlcipher:3.5.1' |
数据库路径设置
1 | File path=new File(Environment.getExternalStorageDirectory(),"BleDemo/db/"+dbName); //设置存储路径 |