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. Get screen coordinates by specific location and longitude

Hy all,

I have an application of augmented reality in which I have stored
information such us metro, gas stations, places of interest, etc. with
the corresponding latitude and longitude.

Now, according to the orientation of the device, I would show a marker
for each site in the camera view of the device. Similar to Layar and

It takes three days searching without stopping and have not found
anyone to explain how to solve this problem. 
0:25 minutes



2. Have to tap 2times to have the data displayed in a ListView...

I don't know why but when tapping the "calculate" button to store the
data calculated, when i goes to the listview the first time it tells
me that there is no data, when i tap again in the button i have all
datas displayed plus the last one!
Here is a video explanation:
And here is the necessary code:
public class Saves extends Activity {
        private Context context;
        protected String[][] s;
        protected String fileDir;
        protected Activity activity;
        private static AlertDialog alert_reset;

        public void updatelv(Activity activity) {
                SharedPreferences preferences =
                String fileName = getResources().getString(R.string.fileName);
                fileDir = "" + preferences.getString("login", "") + "."+
preferences.getString("marque", "") + ".";
                s = myIO.ReadFilePerLine(getApplicationContext(), 
                ListView L = (ListView) findViewById(R.id.lv);
                L.setAdapter(new ArrayAdapter<String>(this, R.layout.list_item,

        public void onCreate(Bundle savedInstanceState) {
                context = getApplicationContext();
                activity = this;
                final SharedPreferences preferences = PreferenceManager
                String fileName = getResources().getString(R.string.fileName);
                fileDir = "" + preferences.getString("login", "") + "."+
preferences.getString("marque", "") + ".";
                s = myIO.ReadFilePerLine(getApplicationContext(), fileDir +

                ListView L = (ListView) findViewById(R.id.lv);

Thank you for your help.


3. Point sprite attenuation does not work because the points have the same size.

4. 3rd Party App Permission Prevents System Intent Broadcast ?

5. plz suggest

6. WTTrade in samsung spica hitam

7. Pause / Jump to next track issue (OMAP 3440)