private static SQLDatabase internalOpenSQLDatabase ( File dbFile , KeyProvider provider ) throws SQLException { boolean runningOnAndroid = Misc . isRunningOnAndroid ( ) ; boolean useSqlCipher = ( provider . getEncryptionKey ( ) != null ) ; try { if ( runningOnAndroid ) { if ( useSqlCipher ) { return ( SQLDatabase ) Class . forName ( "com.cloudant.sync.internal.sqlite.android" + ".AndroidSQLCipherSQLite" ) . getMethod ( "open" , File . class , KeyProvider . class ) . invoke ( null , new Object [ ] { dbFile , provider } ) ; } else { return ( SQLDatabase ) Class . forName ( "com.cloudant.sync.internal.sqlite.android" + ".AndroidSQLite" ) . getMethod ( "open" , File . class ) . invoke ( null , dbFile ) ; } } else { if ( useSqlCipher ) { throw new UnsupportedOperationException ( "No SQLCipher-based database " + "implementation for Java SE" ) ; } else { return ( SQLDatabase ) Class . forName ( "com.cloudant.sync.internal.sqlite" + ".sqlite4java.SQLiteWrapper" ) . getMethod ( "open" , File . class ) . invoke ( null , dbFile ) ; } } } catch ( RuntimeException e ) { throw e ; } catch ( Exception e ) { logger . log ( Level . SEVERE , "Failed to load database module" , e ) ; throw new SQLException ( "Failed to load database module" , e ) ; } }
Internal method for creating a SQLDatabase that allows a null filename to create an in - memory database which can be useful for performing checks but creating in - memory databases is not permitted from outside of this class hence the private visibility .