Android How to use SqlCipher with pre-bundled Sqllite Database?

1,102 views
Skip to first unread message

Pranay Airan

unread,
Jan 22, 2013, 3:03:22 PM1/22/13
to sqlc...@googlegroups.com

I am creating an app with a prebundle database, i am using this tutorial to achieve the same,

http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/

Now how should i secure this prebundle db using SQLcipher? As in sqlcipher tutorials it assumes that you are creating a new database instead of using an exsisting one.

My aim is to prevent anyone seeing the content of my prebundle db.

This question has some techniques but it is not working for the guy

using sqlcipher to encrypt already existing database and opening it on android

Thanks Pranay

Nick Parker

unread,
Jan 22, 2013, 3:15:06 PM1/22/13
to sqlc...@googlegroups.com, Pranay Airan
> <http://stackoverflow.com/questions/13443093/using-sqlcipher-to-encrypt-already-existing-database-and-opening-it-on-android>
>
> Thanks Pranay
>
Hi Pranay,

We have an article that covers integrating SQLCipher for Android into an
application [1]. If you are looking to bundle a encrypted database with
your application, it should be included in the applications assets
folder. You can see we do this with certain test case database files in
our test suite for Android [2]. Example 3 [3] provides the steps to
convert a plain-text database to an encrypted one using the command line
shell.

1. http://sqlcipher.net/sqlcipher-for-android
2. https://github.com/sqlcipher/sqlcipher-android-tests
3. http://sqlcipher.net/sqlcipher-api/#sqlcipher_export

--
Nick Parker

Pranay Airan

unread,
Jan 23, 2013, 9:24:04 AM1/23/13
to sqlc...@googlegroups.com, Pranay Airan
Thanks Nick,

For bundling the encrypted database with my app, i will put it in asset folder. How will i reference it??. I am not able to understand which code to refer in the sqlcipher-test db project, can you point to specific line number and file ?

Also for 3, when i want to convert a unencrypted db with encrypted one. Where should i run ./sqlite3 plaintext.db, what is ./sqlite3 ?,  is it sqlcipher core thing?

I typed that command on terminal and got error

Thanks
Pranay

Nick Parker

unread,
Jan 23, 2013, 9:35:00 AM1/23/13
to sqlc...@googlegroups.com, Pranay Airan
Hi Pranay,

With regard to accessing your database from the assets directory, you
will likely want to copy it to the applications database directory. An
example of this can be found in our test suite here [1]. The ./sqlite3
is in reference to executing the SQLCipher command line shell. In order
to run this binary, you would need to build it, here [2] you will find
instructions for doing so from source.

1.
https://github.com/sqlcipher/sqlcipher-android-tests/blob/master/src/main/java/net/zetetic/ZeteticApplication.java#L46-L60
2. http://sqlcipher.net/introduction/
--
Nick Parker
Reply all
Reply to author
Forward
0 new messages