Securing sensitive data in Android

Storing sensitive information in encrypted preference

Siva Ganesh Kantamani
Programming Geeks

--

Introduction

Storing sensitive data in the Andriod app is a risk from the beginning but things are going to change pretty soon with native Encrypted Shared-preference library from the AndroidX family.

But like everything in android, Encrypted shared-preference also has one flaw. It only supports from Marshmallow(Android 6) and above.

Now, First let’s discuss how to use new encrypted preference library and then we can go through the encryption process for pre android 6 devices.

Integration

MinSDK

minimum SDK version of your app should be 23(Android 6)

minSdkVersion 23

Library integration

Add the following line in the build.gradle of your app, it’s still in alpha stage so make sure you’re not using in production build.

implementation "androidx.security:security-crypto:1.0.0-alpha02"

Let’s see how to work with Encrypted preference

class EncryptedSharedPreferences : SharedPreferences

--

--