将数据存储在位于 Android 智能手机文件系统上的 sqlite 文件中的推荐方法是什么?我打算在设备重启后恢复数据。“DaoMaster.createAllTables(db, true)”和“DaoMaster.createAllTables(db, false)”有什么区别?
目前我在 MainActivity.java 中使用此代码:
db = SQLiteDatabase.openOrCreateDatabase(new File(getExternalFilesDir(null).getPath(),
"opendao.sqlite"), null);
daoMaster = new DaoMaster(db);
DaoMaster.createAllTables(db, true);
daoSession = daoMaster.newSession(db);
locationEntityDao = daoSession.getLocationEntityDao();
locationTraceEntityDao = daoSession.getLocationTraceEntityDao();
photoEntityDao = daoSession.getPhotoEntityDao();
photosEntityDao = daoSession.getPhotosEntityDao();
poiEntityDao = daoSession.getPoiEntityDao();
primitiveAttributesEntityDao = daoSession.getPrimitiveAttributesEntityDao();
我不得不修改生成的 DaoMaster.java:
public DaoSession newSession(SQLiteDatabase db) {
return new DaoSession(db, IdentityScopeType.Session, daoConfigMap);
}