Encrypt database file

by DanielSchH » Tue, 26 Apr 2011 20:41:27 GMT

Sponsored Links

Im looking for a way to secure a SQLite database in Android. I have
read some stuff about sqlcipher but it seems to be quite complicated
to integrate the lib into a Android project and to write a java

So my idea is to create an normal SQLite database and encrypt the
file. Has anybody tried it already or is it not possible.

Thanks a lot,


Re: Encrypt database file

by lbendlin » Tue, 26 Apr 2011 23:52:42 GMT

  http://sqlite-crypt.com/ - but yes , you'll have the same task to incorporate 
the c code into your Java project. Well, tough.


Sponsored Links

Re: Encrypt database file

by DanH » Wed, 27 Apr 2011 09:53:37 GMT

 You can always encrypt/decrypt the DB file each time you end/start the
application.  But if the app dies suddenly the file is left

 You could compile your own version of SqlCipher (I've done it twice
for other platforms -- not exactly rocket science, but it is jet
engine science).  You are faced with the problem of finding a suitable
crypto implementation (ideally OpenSSL).  Easy to just download and
compile a separate copy for yourself if this is for personal use, but
you're apt to run afoul of import/export rules if you try to sell your
app (especially if you ship it from the US).  If you could access the
in-built encryption support that would be ideal (avoids the import/
export problem), but I'm not sure there's a way to get at it.

You can encrypt/decrypt individual rows in the DB as you read/write.
This is inefficient and awkward -- you basically have to put all the
data into one long string, and any search keys must be left in clear
text.  It's also relatively easy to crack.

For small amounts of data it's probably better to put the data into
XML or JSON and read/write the entire file, decrypting/encrypting as
you do the file I/O.


Re: Encrypt database file

by Zsolt Vasvari » Wed, 27 Apr 2011 10:19:34 GMT

 I would just encrypt the really sensitive fields, if anything.  In
most apps, only a very small percentage of the data is really
sensitive.  But, by doing encryption in the application level, you are
going to lose some nice features such as being able to sort or search
on your data.


Other Threads

1. How to compute the screen size before rendering objects?

Hi Everybody,

I want to render 3d object on the screen. Before that I would like to
compute the screen so that the rendered object can be given relative
position. How that can be done?

Can anyone guide me How to go about it?


2. File Browser on Android Phone


how can I browse the contents on my android phone without hooking it
up to a computer. I mean an File Browser Android application

Thanks in advance


3. How to search an application on Android Market?

4. why there's no boot.img in Android-1.5

5. flagNoExtractUi still showing keyboard text area

6. Reusing code, multiple external namespaces

7. Get current locale