geopackage-sdk/src/main/java/mil/nga/geopackage/factory/GeoPackageManagerImpl.java
@Override
    public GeoPackage open(String database, boolean writable) {

        GeoPackage db = null;

        if (exists(database)) {
            GeoPackageCursorFactory cursorFactory = new GeoPackageCursorFactory();
            String path = null;
            SQLiteDatabase sqlite = null;
            GeoPackageMetadata metadata = getGeoPackageMetadata(database);
            if (metadata != null && metadata.isExternal()) {
                path = metadata.getExternalPath();
                if (writable) {
                    try {
                        sqlite = SQLiteDatabase.openDatabase(path,
                                cursorFactory, SQLiteDatabase.OPEN_READWRITE
                                        | SQLiteDatabase.NO_LOCALIZED_COLLATORS);
                    } catch (Exception e) {
                        Log.e(GeoPackageManagerImpl.class.getSimpleName(), "Failed to open database as writable: " + database, e);
                    }
                }
                if (sqlite == null) {
                    sqlite = SQLiteDatabase.openDatabase(path,
                            cursorFactory, SQLiteDatabase.OPEN_READONLY
                                    | SQLiteDatabase.NO_LOCALIZED_COLLATORS);
                    writable = false;
                }
            } else {
                sqlite = context.openOrCreateDatabase(database,
                        Context.MODE_PRIVATE, cursorFactory);
            }
            if(sqliteWriteAheadLogging){
                sqlite.enableWriteAheadLogging();
            }else {
                sqlite.disableWriteAheadLogging();
            }

            // Validate the database if validation is enabled
            validateDatabaseAndCloseOnError(sqlite, openHeaderValidation, openIntegrityValidation);

            GeoPackageConnection connection = new GeoPackageConnection(new GeoPackageDatabase(sqlite));
            GeoPackageTableCreator tableCreator = new GeoPackageTableCreator(connection);
            db = new GeoPackageImpl(context, database, path, connection, cursorFactory, tableCreator, writable);

            // Validate the GeoPackage has the minimum required tables
            try {
                GeoPackageValidate.validateMinimumTables(db);
            } catch (RuntimeException e) {
                db.close();
                throw e;
            }
        }

        return db;
    }
@Override
    public GeoPackage open(String database, boolean writable) {

        GeoPackage db = null;

        if (exists(database)) {
            GeoPackageCursorFactory cursorFactory = new GeoPackageCursorFactory();
            String path = null;
            SQLiteDatabase sqlite = null;
            GeoPackageMetadata metadata = getGeoPackageMetadata(database);
            if (metadata != null && metadata.isExternal()) {
                path = metadata.getExternalPath();
                if (writable) {
                    try {
                        sqlite = SQLiteDatabase.openDatabase(path,
                                cursorFactory, SQLiteDatabase.OPEN_READWRITE
                                        | SQLiteDatabase.NO_LOCALIZED_COLLATORS);
                    } catch (Exception e) {
                        Log.e(GeoPackageManagerImpl.class.getSimpleName(), "Failed to open database as writable: " + database, e);
                    }
                }
                if (sqlite == null) {
                    sqlite = SQLiteDatabase.openDatabase(path,
                            cursorFactory, SQLiteDatabase.OPEN_READONLY
                                    | SQLiteDatabase.NO_LOCALIZED_COLLATORS);
                    writable = false;
                }
            } else {
                sqlite = context.openOrCreateDatabase(database,
                        Context.MODE_PRIVATE, cursorFactory);
            }
            if(sqliteWriteAheadLogging){
                sqlite.enableWriteAheadLogging();
            }else {
                sqlite.disableWriteAheadLogging();
            }

            // Validate the database if validation is enabled
            validateDatabaseAndCloseOnError(sqlite, openHeaderValidation, openIntegrityValidation);

            GeoPackageConnection connection = new GeoPackageConnection(new GeoPackageDatabase(sqlite));
            GeoPackageTableCreator tableCreator = new GeoPackageTableCreator(connection);
            db = new GeoPackageImpl(context, database, path, connection, cursorFactory, tableCreator, writable);

            // Validate the GeoPackage has the minimum required tables
            try {
                GeoPackageValidate.validateMinimumTables(db);
            } catch (RuntimeException e) {
                db.close();
                throw e;
            }
        }

        return db;
    }
{@inheritDoc}