Java Code Examples for net.sqlcipher.database.SQLiteDatabaseHook

The following examples show how to use net.sqlcipher.database.SQLiteDatabaseHook. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private void export(DatabaseUserConfiguration oldConfiguration,
                    DatabaseUserConfiguration newConfiguration, String oldPassword, String newPassword, String tag,
                    SQLiteDatabaseHook oldHook, SQLiteDatabaseHook newHook) {
    wrapAction(() -> {
        File oldDatabaseFile = context.getDatabasePath(oldConfiguration.databaseName());
        File newDatabaseFile = context.getDatabasePath(newConfiguration.databaseName());

        SQLiteDatabase oldDatabase = SQLiteDatabase.openOrCreateDatabase(oldDatabaseFile, oldPassword, null,
                "ATTACH DATABASE '%s' as alias KEY '%s';", newDatabaseFile.getAbsolutePath(), newPassword));
        if (newHook != null) {
            oldDatabase.rawExecSQL("PRAGMA alias.cipher_page_size = 16384;");
            oldDatabase.rawExecSQL("PRAGMA alias.cipher_memory_security = OFF;");
        oldDatabase.rawExecSQL("SELECT sqlcipher_export('alias');");
        oldDatabase.rawExecSQL("DETACH DATABASE alias;");

        int version = oldDatabase.getVersion();
        SQLiteDatabase newDatabase = SQLiteDatabase.openOrCreateDatabase(newDatabaseFile, newPassword, null,

    }, tag);
Example 2
Source Project: commcare-android   Source File:    License: Apache License 2.0 4 votes vote down vote up
public void __constructor__(String path, char[] password, CursorFactory factory, int flags, SQLiteDatabaseHook hook) {
    db = android.database.sqlite.SQLiteDatabase.openDatabase(path, null, flags);