数据库读写操作import net.sqlcipher.Cursor;import net.sqlcipher.SQLException;import net.sqlcipher.database.SQLiteDatabase;import net.sqlcipher.database.SQLiteDatabaseHook;
SQLiteDatabase.loadLibs(context);
SQLiteDatabaseHook hook = new SQLiteDatabaseHook() { @Override
public void preKey(SQLiteDatabase database) {
} @Override
public void postKey(SQLiteDatabase database) {
database.rawExecSQL("PRAGMA cipher_migrate;"); // 兼容2.0的数据库
}
};
String file = "数据库备份后的文件路径;
String password = "秘钥";
SQLiteDatabase database = SQLiteDatabase.openOrCreateDatabase(file, password, null, hook);
... ...