openDatabases method
使用hive数据库 路径可以为空
Implementation
Future<void> openDatabases({required List<UMEDatabase> databases}) async {
for (var data in databases) {
if (data is SqliteDatabas) {
SqliteDatabas sqliteDataba = data;
sqliteHelper = SqliteHelper();
var path = await sqliteHelper.initDeleteDb(data.databaseName,
deleteDB: data.isDeleteDB);
var db = await openDatabase(path,
version: 1,
onCreate: data.onCreate,
onConfigure: data.onConfigure,
onDowngrade: data.onDowngrade,
onOpen: data.onOpen,
onUpgrade: data.onUpgrade,
readOnly: false);
sqliteDataba.db = db;
sqliteHelper.sqliteDatabas = sqliteDataba;
this.databases.add(sqliteDataba);
if (sqliteDataba.updateMap.isNotEmpty) {
for (var sum in sqliteDataba.updateMap) {
sqliteHelper.addSqliteUpdateConditions(sum);
}
}
} else if (data is HiveDatabase) {
hiveHelper = HiveHelper();
HiveDatabase hiveDatabase = data;
this.databases.add(hiveDatabase);
} else if (data is SharedPreferencesDatabase) {
sharedPreferencesHelper =
SharedPreferencesHelper(data.sharedPreferences);
SharedPreferencesDatabase sharedPreferencesDatabase = data;
if (sharedPreferencesDatabase.deleteDB()) {
await sharedPreferencesDatabase.sharedPreferences.clear();
}
this.databases.add(sharedPreferencesDatabase);
}
}
}