Search in sources :

Example 1 with EncryptedDatabase

use of org.greenrobot.greendao.database.EncryptedDatabase in project greenDAO by greenrobot.

the class EncryptedDbUtils method createDatabase.

public static Database createDatabase(Context context, String dbName, String password) {
    if (!loadedLibs) {
        loadedLibs = true;
        SQLiteDatabase.loadLibs(context);
    }
    SQLiteDatabase sqLiteDatabase;
    if (dbName == null) {
        sqLiteDatabase = SQLiteDatabase.create(null, password);
    } else {
        File dbFile = context.getDatabasePath(dbName);
        dbFile.getParentFile().mkdir();
        context.deleteDatabase(dbName);
        sqLiteDatabase = SQLiteDatabase.openOrCreateDatabase(dbFile, password, null);
    }
    return new EncryptedDatabase(sqLiteDatabase);
}
Also used : SQLiteDatabase(net.sqlcipher.database.SQLiteDatabase) EncryptedDatabase(org.greenrobot.greendao.database.EncryptedDatabase) File(java.io.File)

Aggregations

File (java.io.File)1 SQLiteDatabase (net.sqlcipher.database.SQLiteDatabase)1 EncryptedDatabase (org.greenrobot.greendao.database.EncryptedDatabase)1