sqlite vs realm in terms of data security from hackers sqlite vs realm in terms of data security from hackers sqlite sqlite

sqlite vs realm in terms of data security from hackers


Both Realm and SQLite use files stored in your app's private directory within the internal storage. This is safe enough for most cases since no app apart from yours is allowed to access it.

However, you have to take account on rooted devices. With those, users can navigate the whole filesystem with ease, including your app's private directory.

Given this, our best bet relies on data encryption.

Realm supports AES-256 encryption if you asked for it:

byte[] key = new byte[64];new SecureRandom().nextBytes(key);RealmConfiguration config = new RealmConfiguration.Builder(context)  .encryptionKey(key)  .build();Realm realm = Realm.getInstance(config);

Accessing Realm with those will transparently encrypt/decrypt any data that is persisted to disk. Which improves security without needing extra effort from your side as the developer.

This project demoes how you can make use of Realm's encryption feature.

As for SQLite… I haven't found anything yet. Maybe your best bet is to manually do the encryption/decryption yourself.