1

I have an android application in wich I can export/inport my database to sdcard.

I do it simply by using:

FileChannel src = new FileInputStream(currentDB).getChannel();
FileChannel dst = new FileOutputStream(backupDB).getChannel();
dst.transferFrom(src, 0, src.size());
src.close();
dst.close();

What I would like to do is to password protect my exported database so if anyone tries to open it using sqlite browsing programms they would need to enter a password.

Can this be done(and how)?

Tadej Vengust
  • 1,351
  • 4
  • 18
  • 35
  • I don't think you can password protect a sqlite database but what you can do is encrypt the data using a password. –  Mar 18 '15 at 15:03

1 Answers1

1

Instead of protect database, you could encrypt file (exported database) there's some threads talking about this:

How to encrypt and decrypt file in Android?

Encrypting files with AES on Android

UPDATE1:

To decrypt file on desktop, there's this thread:

Decrypting data on desktop that was encrypted on android

Community
  • 1
  • 1
LaurentY
  • 7,495
  • 3
  • 37
  • 55
  • @TadejVengust, is it useful ? – LaurentY Mar 20 '15 at 10:33
  • Yes thank you, but no where does it say how I can then decrypt the file on my computer not on android. :( – Tadej Vengust Mar 25 '15 at 08:38
  • So if I want to password protect my database I have to encrypt my whole file when exporting and then decrpyt it on my computer with a program I write in java? There is no easyer way? because I will export and import very frequently and this will consume quite some time. – Tadej Vengust Mar 28 '15 at 12:16
  • @TadejVengust You're right regarding the process to encrypt/decrypt. There's some commercial libraries to help you to do it as https://www.zetetic.net/sqlcipher/ . Regarding time to encrypt/decrypt you're right it take lot of time. You could use an hardware crypto processor to increase speed. – LaurentY Mar 30 '15 at 07:39