如何使用SQLiteOpenHelper何时执行SQLCipher [英] How to implement SQLCipher when using SQLiteOpenHelper

查看:654
本文介绍了如何使用SQLiteOpenHelper何时执行SQLCipher的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过在一个Android应用程序我已经存在和运作的数据库设置实施加密来保护一些明智的数据。

I am trying to secure some sensible data by implementing encryption in my already existing and functioning database setup in an android application.

我想按照这个教程( http://sqlcipher.net/sqlcipher-for-android/ )我浏览了很多foruns,包括谷歌组密码。不过,我还是不清楚地了解如何做SQLCipher工作,我应该如何适应我的code,以满足我的需求。

I tried to follow this tutorial (http://sqlcipher.net/sqlcipher-for-android/) and I browsed a lot of foruns, including the google group for Cipher. However, I still don't clearly understand how does SQLCipher work and how I should adapt my code to serve my needs.

我下面这个实现在Android的数据库:<一href="http://www.vogella.com/articles/AndroidSQLite/#databasetutorial_database">http://www.vogella.com/articles/AndroidSQLite/#databasetutorial_database,这意味着我有SQLiteOpenHelper类的扩展,另一个类存储的CRUD方法。

I am following this implementation of databases in android: http://www.vogella.com/articles/AndroidSQLite/#databasetutorial_database, meaning I have an extension of the SQLiteOpenHelper class and another class to store CRUD methods.

在这种情况下,我应该如何使用SQLCipher?我应该在哪里定义密码?我应该在哪里使用loadLibs(上下文)?只有在主要活动?或者,在每一个访问数据库的活动呢?

In this situation how should I use SQLCipher? Where should I define the password? Where should I use loadLibs(context)? Only in the main activity? Or in every activity that accesses the database?

我觉得我几乎没有,我只需要最后冲刺阶段摸不着头脑:P 在此先感谢!

I feel I'm almost there, I just need the final push to figure this out :P Thanks in advance!

推荐答案

在这种情况下,我应该如何使用SQLCipher?

酷似一个普通正常的SQL实现。

我应该在哪里定义密码?

如果您使用的是SQLiteHelper它会创建数据库时,你第一次得到这样的:

helper.getWriteableDatabase("myPassword");

在第一次调用它会创建数据库使用此密码。在upcoing调用它只能与该密码的工作。

(想通了这一点,当我走到来源:<一href="https://github.com/sqlcipher/android-database-sqlcipher/blob/master/src/net/sqlcipher/database/SQLiteOpenHelper.java">https://github.com/sqlcipher/android-database-sqlcipher/blob/master/src/net/sqlcipher/database/SQLiteOpenHelper.java,检出方法getWriteableDatabase(字符串PW)  那里! )

( Figured that out when i went to the Source: https://github.com/sqlcipher/android-database-sqlcipher/blob/master/src/net/sqlcipher/database/SQLiteOpenHelper.java, checkout the method getWriteableDatabase( String pw ) there! )

我应该在哪里使用loadLibs(上下文)?

你叫 helper.getWriteableDatabase(MYPASSWORD)权利的;! 第一次

这篇关于如何使用SQLiteOpenHelper何时执行SQLCipher的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆