如何开始使用SQLCipher为Android? [英] How to get started with SQLCipher for android?

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

问题描述

我需要使用SQLCipher为Android ...我已经取得了使用我的应用程序的SQLite,并希望只是将其转换为SQLCipher。

I need to use SQLCipher for android...i've already made my app using SQLite and want to just convert it to SQLCipher.

现在的问题是,我什么都不知道SQLCipher。

The problem is, I know nothing about SQLCipher.

我在这个链接读到它:<一href="http://sqlcipher.net/sqlcipher-for-android/">http://sqlcipher.net/sqlcipher-for-android/

但我不是太清楚,还是。 我想知道,如果你能为Android教程,这里的一切是从绝对的基础知识教一个简单的方法提供一些基本的sqlcipher。

But i'm not too clear, still. I was wondering if you could provide some basic sqlcipher for android tutorials, where everything is taught in an easy way from the absolute basics.

谢谢!

推荐答案

要正确使用SQL密码为Android则必须使用外部库,并修改某些code这与你的数据库进行交互。

To properly use SQL Cipher for Android you must use external libraries and change some of the code which interacts with your DB.

  1. 这些必须首先被添加到您的项目(libs文件夹中。)请参阅这里得到这些:<一href="http://sqlcipher.net/sqlcipher-for-android/">http://sqlcipher.net/sqlcipher-for-android/

其次,你需要将icudt4dl.zip文件添加到您的资产文件夹,这个邮编自带的SQL密码库。

Secondly you need to add the icudt4dl.zip file to your assets folder, this Zip comes with the SQL Cipher libraries.

右键单击您的项目,进入属性,然后Java构建路径则包括诸如commons- codec.jar,番石榴r09.jar,sqlcipher.jar库。一旦做到这一点,做一个构建清洁。

Right click your project, go to properties then Java build path then include libraries such as commons-codec.jar, guava-r09.jar, sqlcipher.jar. Once this is done, do a build clean.

那么你的应用程序中,进口替代android.database.sqlite,您将导入进口net.sqlcipher.database

Then within your App, instead of importing android.database.sqlite, you will import import net.sqlcipher.database

更​​改任何code这与DB,例如交互:

Change any code which interacts with the DB, example:

SQLiteDatabase.loadLibs(上下文);

SQLiteDatabase.loadLibs(context);

字符串DBPATH = this.getDatabasePath(dbname.db)getPath();

String dbPath = this.getDatabasePath("dbname.db").getPath();

SQLiteDatabase DB = SQLiteDatabase.openOrCreateDatabase(DBPATH,DBPASSWORD,NULL);

SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(dbPath,"dbPassword", null);

验证数据库进行加密,到DDMS透视图在Eclipse中,单击文件浏览器选项卡,导航到数据/数据​​/,点击.db文件,并选择获取设备文件,将其保存到桌面并用文本编辑器打开它。外观为纯文本值,你已经被插入到你的数据库,如果你仍然可以阅读,出了问题。

Verify that the database is encrypted, go to DDMS perspective in Eclipse, click the file explorer tab, navigate to data/data/, click on the .db file and select get device file, save it to your desktop and open it with a text editor. Look for the plain text values you have been inserting into your database, if you can still read them, something has gone wrong.

这也可能是一个不错的主意执行SQL密码前检查出一些SQLite的教程。一个很好的就是这里所说的: <一href="http://stackoverflow.com/questions/11230147/android-sqlite-database-where-do-i-start-as-the-tutorial-has-gone-for-notepad">Android SQLite数据库 - ?从哪里开始的教程已经记事本

It might also be a good idea to check out some SQLite tutorials before implementing SQL Cipher. A good one is mentioned here: Android sqlite database - where do i start as the tutorial has gone for notepad?

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

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