geopackage-sdk/src/main/java/mil/nga/geopackage/factory/GeoPackageManagerImpl.java
private boolean isValid(String database, boolean validateHeader, boolean validateIntegrity) {

        boolean valid = false;

        if (exists(database)) {
            GeoPackageCursorFactory cursorFactory = new GeoPackageCursorFactory();
            String path = null;
            SQLiteDatabase sqlite;
            GeoPackageMetadata metadata = getGeoPackageMetadata(database);
            if (metadata != null && metadata.isExternal()) {
                path = metadata.getExternalPath();
                try {
                    sqlite = SQLiteDatabase.openDatabase(path,
                            cursorFactory, SQLiteDatabase.OPEN_READWRITE
                                    | SQLiteDatabase.NO_LOCALIZED_COLLATORS);
                } catch (Exception e) {
                    sqlite = SQLiteDatabase.openDatabase(path,
                            cursorFactory, SQLiteDatabase.OPEN_READONLY
                                    | SQLiteDatabase.NO_LOCALIZED_COLLATORS);
                }
            } else {
                path = context.getDatabasePath(database).getAbsolutePath();
                sqlite = context.openOrCreateDatabase(database,
                        Context.MODE_PRIVATE, cursorFactory);
            }

            try {
                valid = (!validateHeader || isDatabaseHeaderValid(sqlite))
                        && (!validateIntegrity || sqlite.isDatabaseIntegrityOk());
            } catch (Exception e) {
                Log.e(GeoPackageManagerImpl.class.getSimpleName(), "Failed to validate database", e);
            } finally {
                sqlite.close();
            }
        }

        return valid;
    }
private boolean isValid(String database, boolean validateHeader, boolean validateIntegrity) {

        boolean valid = false;

        if (exists(database)) {
            GeoPackageCursorFactory cursorFactory = new GeoPackageCursorFactory();
            String path = null;
            SQLiteDatabase sqlite;
            GeoPackageMetadata metadata = getGeoPackageMetadata(database);
            if (metadata != null && metadata.isExternal()) {
                path = metadata.getExternalPath();
                try {
                    sqlite = SQLiteDatabase.openDatabase(path,
                            cursorFactory, SQLiteDatabase.OPEN_READWRITE
                                    | SQLiteDatabase.NO_LOCALIZED_COLLATORS);
                } catch (Exception e) {
                    sqlite = SQLiteDatabase.openDatabase(path,
                            cursorFactory, SQLiteDatabase.OPEN_READONLY
                                    | SQLiteDatabase.NO_LOCALIZED_COLLATORS);
                }
            } else {
                path = context.getDatabasePath(database).getAbsolutePath();
                sqlite = context.openOrCreateDatabase(database,
                        Context.MODE_PRIVATE, cursorFactory);
            }

            try {
                valid = (!validateHeader || isDatabaseHeaderValid(sqlite))
                        && (!validateIntegrity || sqlite.isDatabaseIntegrityOk());
            } catch (Exception e) {
                Log.e(GeoPackageManagerImpl.class.getSimpleName(), "Failed to validate database", e);
            } finally {
                sqlite.close();
            }
        }

        return valid;
    }
private boolean isValid ( String database , boolean validateHeader , boolean validateIntegrity ) { boolean valid = false ; if ( exists ( database ) ) { GeoPackageCursorFactory cursorFactory = new GeoPackageCursorFactory ( ) ; String path = null ; SQLiteDatabase sqlite ; GeoPackageMetadata metadata = getGeoPackageMetadata ( database ) ; if ( metadata != null && metadata . isExternal ( ) ) { path = metadata . getExternalPath ( ) ; try { sqlite = SQLiteDatabase . openDatabase ( path , cursorFactory , SQLiteDatabase . OPEN_READWRITE | SQLiteDatabase . NO_LOCALIZED_COLLATORS ) ; } catch ( Exception e ) { sqlite = SQLiteDatabase . openDatabase ( path , cursorFactory , SQLiteDatabase . OPEN_READONLY | SQLiteDatabase . NO_LOCALIZED_COLLATORS ) ; } } else { path = context . getDatabasePath ( database ) . getAbsolutePath ( ) ; sqlite = context . openOrCreateDatabase ( database , Context . MODE_PRIVATE , cursorFactory ) ; } try { valid = ( ! validateHeader || isDatabaseHeaderValid ( sqlite ) ) && ( ! validateIntegrity || sqlite . isDatabaseIntegrityOk ( ) ) ; } catch ( Exception e ) { Log . e ( GeoPackageManagerImpl . class . getSimpleName ( ) , "Failed to validate database" , e ) ; } finally { sqlite . close ( ) ; } } return valid ; }
Validate the GeoPackage database

@param database
@param validateHeader    true to validate the header of the database
@param validateIntegrity true to validate the integrity of the database
@return true if valid
Validate the GeoPackage database