rcorbellini
rcorbellini

Reputation: 1337

Encrypt android database , dont working (apparently)

I do all process to encrypt database of android: Setting>security>Encrypt phone

Then i try get my database of android

$ adb shell
$ run-as com.your.package cat /data/data/com.your.package/databases/your_db > /storage/sdcard0/Download/your.db

and result is all of my data are not encrypt....

i do another test and reeinstal my app, and get my database again, all data stay uncrypted...

what i need to do, to encrypt my database (without code), and how i can check this data encrypted?

---edited---

if i test encrypt with this code, i get return "true", but i still can acess the .db and read all information...

@SuppressLint("NewApi")
    public static boolean isEncrypted(Context context) {
        DevicePolicyManager devicePolicyManager = (DevicePolicyManager) context
                .getSystemService(Context.DEVICE_POLICY_SERVICE);

        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) {
            int status = devicePolicyManager.getStorageEncryptionStatus();
            if (DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE == status) {
                return true;
            }
        }
        return false;
    }

Upvotes: 0

Views: 72

Answers (1)

antonio
antonio

Reputation: 18262

From the documentation:

Once a device is encrypted, all user-created data is automatically encrypted before committing it to disk and all reads automatically decrypt data before returning it to the calling process.

And from the article you mention on your question:

So even if someone pulls all the data off your phone, circumventing the lock screen, the data will be useless without your key.

So, your data is encrypted while it's on your phone and protected by your lock (for example a PIN lock).

When you connect the device to a computer via USB, as long as you have entered your PIN correctly, the operation is considered safe and your data will be decrypted before it's sent to your computer.

Upvotes: 1

Related Questions