1

dbプレーン データベース ( ) から SQLCipher で暗号化された接続データベース ( ) にデータをコピーしようとすると、「そのようなテーブルはありません」という例外が発生しますsource

    StringBuilder attachDatabase = new StringBuilder();
    attachDatabase.append("ATTACH DATABASE '").append(this.db.getPath()).
                    append("' as ").append(NEW_DB_ALIAS).
                    append(" KEY '").append("123").append("';");
    source.execSQL(attachDatabase.toString());

    StringBuilder copyTable = new StringBuilder();
    String table = "t1";
    copyTable.append("INSERT INTO ").append(NEW_DB_ALIAS).append(".").append(table).
                append(" SELECT * FROM ").append(table).append(";");
    db.execSQL(copyTable.toString());

暗号化されたデータベースが作成され、暗号化されていないデータベースと同じスキームになります。何が問題なのですか?

4

1 に答える 1

0

使用している Android 用 SQLCipher のバージョンを確認していただけますか? 最近、こちらから入手できるライブラリの 1.0 をリリースしました: https://github.com/downloads/guardianproject/android-database-sqlcipher/SQLCipherForAndroid-SDK-0.0.6-FINAL.zip

実行前に新しいデータベース ファイルが存在せず、正常に動作する次のシナリオを実行しました。最初にスキーマを使用して新しいデータベースを作成せずに、これを試してみることができますか:

    String newKey = "foo";
    File newDatabasePath = getDatabasePath("new.db");
    String attachCommand = "ATTACH DATABASE ? as encrypted KEY ?";
    String createCommand = "create table encrypted.t1(a,b)";
    String insertCommand = "insert into encrypted.t1 SELECT * from t1";
    String detachCommand = "DETACH DATABASE encrypted";
    encryptedDatabase.execSQL(attachCommand, new Object[]{newDatabasePath.getAbsolutePath(), newKey});
    encryptedDatabase.execSQL(createCommand);
    encryptedDatabase.execSQL(insertCommand);
    encryptedDatabase.execSQL(detachCommand);
于 2011-12-22T20:36:31.490 に答える