/** * Verify schema. * * @param <H> * the generic type * @param dataSource * the data source * @param inputStream * the input stream */ public static <H extends AbstractDataSource> void verifySchema(H dataSource, InputStream inputStream) { verifySchema(dataSource.openWritableDatabase(), inputStream); }
/** * Verify schema. * * @param <H> * the generic type * @param dataSource * the data source * @param context * the context * @param rawId * the raw id */ public static <H extends AbstractDataSource> void verifySchema(H dataSource, Context context, int rawId) { verifySchema(dataSource.openWritableDatabase(), context, rawId); }
/** * Force a schema update for a datasource. Note that no DDL was execute * untill the database was opened. * * @param <H> * the element type * @param dataSource * the data source * @param version * to upgrade. */ public static <H extends AbstractDataSource> void forceDataSourceSchemaUpdate(H dataSource, int version) { dataSource.forceClose(); dataSource.version = version; dataSource.database = null; dataSource.sqliteHelper = null; dataSource.openWritableDatabase(); }
/** * Clear datasource. * * @param <H> * the element type * @param dataSource * the data source */ public static <H extends AbstractDataSource> void clearDataSource(H dataSource) { if (dataSource.options.inMemory) { dataSource.close(); return; } dataSource.openWritableDatabase(); File file = new File(dataSource.database.getPath(), dataSource.name); if (dataSource.isOpen()) { dataSource.forceClose(); dataSource.close(); } Logger.info("Clear database file %s", file.getAbsolutePath()); if (!file.delete()) { Logger.warn("Can not delete database " + file.getAbsolutePath()); } }