我正在尝试在我的Android应用程序中附加现有的sqlcipher数据库(加密),但在我的目录中复制后,无法使用"SQLiteDatabase.openDatabase(...)"打开它
我在普通的sqlite中尝试了代码并且它可以正常工作,但是当我使用sqlcipher API时,我收到了此错误消息
//CREATE TABLE android_metadata failed
//Failed to setLocale() when constructing, closing the database
// net.sqlcipher.database.SQLiteException: file is encrypted or is not a database
Run Code Online (Sandbox Code Playgroud)
我在SQLiteOpenHelper类中使用了以下代码:
if(!dbExist1)
{
this.getWritableDatabase(password);
this.openDatabase();
try
{
this.close();
copyDataBase();
}
catch (IOException e)
{
throw new Error("Error copying database");
}
}
public SQLiteDatabase openDatabase() throws SQLException {
String DBPath = DATABASE_PATH + DATABASE_NAME;
myDataBase = SQLiteDatabase.openDatabase(DBPath, password, null,
SQLiteDatabase.NO_LOCALIZED_COLLATORS);
return myDataBase;
}
Run Code Online (Sandbox Code Playgroud)
我在Activity Class中使用了以下代码:
SQLiteDatabase.loadLibs(this);
DataBaseHelper myDbHelper ;
myDbHelper = new DataBaseHelper(this);
SQLiteDatabase db=myDbHelper.openDatabase();
Run Code Online (Sandbox Code Playgroud)
我试图使用 …