app/src/main/java/db/juhaku/juhakudb/core/android/DatabaseHelper.java
/**
     * Tries to restore {@link Schema} by given old version.
     * @param oldVersion int value of old version of the schema.
     * @return instance of {@link Schema} if restoration is successful. If schema could not
     * be restored nor it is not found null will be returned instead.
     */
Tries to restore  Schema by given old version.
@param oldVersion int value of old version of the schema.
@return instance of  Schema if restoration is successful. If schema could not
be restored nor it is not found null will be returned instead.
Tries to restore Schema by given old version . @param oldVersion int value of old version of the schema . @return instance of Schema if restoration is successful . If schema could not be restored nor it is not found null will be returned instead .
private Schema restoreSchema(int oldVersion) {
        Schema schema = null;
        File schemaFolder = getSchemaFolder();
        int currentVersion = databaseConfiguration.getVersion();
        databaseConfiguration.setVersion(oldVersion);
        String schemaFileName = generateSchemaName(databaseConfiguration);
        databaseConfiguration.setVersion(currentVersion);
        File schemaFile = new File(schemaFolder.getAbsolutePath(), schemaFileName);
        if (schemaFile.exists()) {
            ObjectInputStream in = null;
            try {
                in =  new ObjectInputStream(new FileInputStream(schemaFile));
                schema = (Schema) in.readObject();
            } catch (IOException | ClassNotFoundException e) {
                Log.e(getClass().getName(), "Schema restoration failed", e);
            } finally {
                closeStream(in);
            }
        }
        return schema;
    }
private Schema restoreSchema ( int oldVersion ) { Schema schema = null ; File schemaFolder = getSchemaFolder ( ) ; int currentVersion = databaseConfiguration . getVersion ( ) ; databaseConfiguration . setVersion ( oldVersion ) ; String schemaFileName = generateSchemaName ( databaseConfiguration ) ; databaseConfiguration . setVersion ( currentVersion ) ; File schemaFile = new File ( schemaFolder . getAbsolutePath ( ) , schemaFileName ) ; if ( schemaFile . exists ( ) ) { ObjectInputStream in = null ; try { in = new ObjectInputStream ( new FileInputStream ( schemaFile ) ) ; schema = ( Schema ) in . readObject ( ) ; } catch ( IOException | ClassNotFoundException e ) { Log . e ( getClass ( ) . getName ( ) , "Schema restoration failed" , e ) ; } finally { closeStream ( in ) ; } } return schema ; }
Tries to restore {@link Schema} by given old version.
Tries to restore { @link Schema } by given old version .
// try closing the stream