Android - net.sqlcipher.database.SQLiteException: error code 14: Could not open database


#1

Hi,
I am not able to integrate SQLCipher to my Android app.
App is throwing -
net.sqlcipher.database.SQLiteException: error code 14: Could not open database

Here is the code snippet

private static SQLiteDatabaseHook keyHook = new SQLiteDatabaseHook() {
@Override
public void preKey(SQLiteDatabase database) {
database.rawExecSQL(“PRAGMA cipher_license = '” + SQL_CIPHER_LICENSE + “’;”);
}

public void postKey(SQLiteDatabase database) {
}

};

public static void initializeSQLCipher(Context context) {
SQLiteDatabase.loadLibs(context);
File databaseFile = new File(getDatabasePath());
databaseFile.mkdirs();
databaseFile.delete();
SQLiteDatabase database = SQLiteDatabase.openOrCreateDatabase(databaseFile, PWD, null, keyHook);
}

References -
https://www.zetetic.net/sqlcipher/sqlcipher-for-android/


#2

Hi @Shailendra_singh

We’ve responded to you via your private support request. For anyone else looking on, Error code 14 is usually due to a file permission issue, e.g. the path is not writable.