I am using SQLite database in my application. I want to make my SQLite database password protected.
-
http://stackoverflow.com/questions/1381264/password-protect-a-sqlite-db-is-it-possible ? – Saro Taşciyan Dec 17 '12 at 11:57
-
try MessageDigest check this http://stackoverflow.com/questions/3934331/android-how-to-encrypt-a-string – Youddh Dec 17 '12 at 12:23
2 Answers
HWACI (the commercial arm behind SQLite development) provides (for money) an encryption engine called SEE. It's quite painless to integrate this in if you are building your own SQLite source, and it's also very easy to use.
SQLCipher is an open source alternative to SEE. I've never used it but I would expect it's as easy to integrate and use as SEE.

- 39,056
- 9
- 76
- 93
As far as I know: no, you can't do it in a simply way.
Posible choices:
-You could simply encrypt the data you want to be secure when inserting it and decrypting the values when you want to play with them. In my opinion this is the best choice.
-You could encrypt the db file in your app's folder. And decrypt it every time you want to access it (not very recommended).
Also note that your DB file is stored in your app's private directory, so in most terminals (except for rooted ones) neither the user nor other apps will have r/w access.
EDIT: For the first choice, I recommend you to take a look to mah's answer if you don't want to implement your own encryption methods =)

- 1,037
- 12
- 19
-
There are encryption extensions to SQLite that make it simple. Also, with the relative ease of rooting Android devices, being in an app's private directory is pretty meaningless. – mah Dec 17 '12 at 11:58
-
@mah Yep, probably the apply the first choice I posted, but I don't know any. Could you provide us some lib example? – Aballano Dec 17 '12 at 12:00
-
@Shyish yes, there are two (one commercial and supported, the other open source) in my answer. These remove the responsibility of encrypting your data manually, applying encryption to the entire database. – mah Dec 17 '12 at 12:02