Hi everyone. I have a problem when trying to export my database. I have exeption:
net.sqlcipher.database.SQLiteException: unable to open database
My code:
String dbPath = context.getDatabasePath(DATABASE_NAME).getPath();
File dbPathFile = new File(dbPath);
if (!dbPathFile.exists())
dbPathFile.getParentFile().mkdirs();
SQLiteDatabase database = SQLiteDatabase.openDatabase(dbPath, password, null, 0);
database.rawExecSQL("PRAGMA key = '" + password + "'");
database.rawExecSQL("ATTACH DATABASE '" + DATABASE_NAME + "' AS SQLChiperSample KEY ''");
database.rawExecSQL("SELECT sqlcipher_export('SQLChiperSample')");
database.rawExecSQL("DETACH DATABASE SQLChiperSample");
The error appears on this line:
database.rawExecSQL("ATTACH DATABASE '" + DATABASE_NAME + "' AS SQLChiperSample KEY ''");
What’s the error?