I'd like to use Core Data in my application, which contains sensitive information. So I would like to protect it from being accessed, even on phones which aren't locked.
Right now I'm encrypting the sqlite, sqlite-shm and sqlite-wal files in didEnterBackground:
and decrypt them again in applicationWillEnterForeground:
. It works as expected, but I don't know if that's the best way to do. E.g. if my application crashes, it won't encrypt the files.
Encrypting and decrypting single entries/columns in the database isn't the best option as well, because then I can't use predicates, right?
So what's the 'state of the art'? Is there a way to have the sqlite file only decrypted whenever the app is opened?
As the app is >= iOS 7, wWould be checking the encrypted/decrypted state periodically (while the app is in the background) an option? But if the user turns of background refresh I'm lost again...