現時点では、私のsqlite dbファイルは暗号assets
化されておらず、フォルダーからアプリケーションフォルダーにコピーされていdata/data/mypackage/databases
ます。
次に、 SQLCipherライブラリをプロジェクトに追加して、使用を開始します。dbファイルを暗号化してコピーしassets
、アプリケーション内で同じキーを使用できますか?Windowsでデータベースを暗号化することは可能ですか?私は何をする必要がありますか?
現時点では、私のsqlite dbファイルは暗号assets
化されておらず、フォルダーからアプリケーションフォルダーにコピーされていdata/data/mypackage/databases
ます。
次に、 SQLCipherライブラリをプロジェクトに追加して、使用を開始します。dbファイルを暗号化してコピーしassets
、アプリケーション内で同じキーを使用できますか?Windowsでデータベースを暗号化することは可能ですか?私は何をする必要がありますか?
私たちはそのようにすべきだと思います
SQLiteDatabase normalDB = null;
SQLiteDatabase cryptedDB = null;
normalDB = SQLiteDatabase.openDatabase(dbPath, "", null,
SQLiteDatabase.OPEN_READONLY
| SQLiteDatabase.NO_LOCALIZED_COLLATORS);
cryptedDB = SQLiteDatabase.openOrCreateDatabase(
encrypteddbPath, Constants.CRYPT_KEY, null);
Cursor cursor;
cursor = normalDB.query(TABLE_CITY,
new String[] { FIELD_CITY_CODE, FIELD_NAME1,
FIELD_NAME2, FIELD_NAME3 }, null, null, null,
null, null);
int i = cursor.getCount();
while (i > 0) {
ContentValues newLabelValues = new ContentValues();
newLabelValues.put(FIELD_CITY_CODE, cursor.getString(0));
newLabelValues.put(FIELD_NAME1, cursor.getString(1));
newLabelValues.put(FIELD_NAME2, cursor.getString(2));
newLabelValues.put(FIELD_NAME3, cursor.getString(3));
cryptedDB.insert(TABLE_CITY, null, newLabelValues);
cursor.moveToNext();
}