Android Keystore for Secure Data Storage

SharedPreferences in Android store tokens, API keys, and session data in plaintext. According to statistics, over 60% of Android apps do not encrypt sensitive information. With physical access or via backups, data can be easily extracted. We use the <cite>[Android Keystore System](https://developer.

Development and support of all types of mobile applications:

Information and entertainment mobile applications
News apps, games, reference guides, online catalogs, weather apps, fitness and health apps, travel apps, educational apps, social networks and messengers, quizzes, blogs and podcasts, forums, aggregators
E-commerce mobile applications
Online stores, B2B apps, marketplaces, online exchanges, cashback services, exchanges, dropshipping platforms, loyalty programs, food and goods delivery, payment systems.
Business process management mobile applications
CRM systems, ERP systems, project management, sales team tools, financial management, production management, logistics and delivery management, HR management, data monitoring systems
Electronic services mobile applications
Classified ads platforms, online schools, online cinemas, electronic service platforms, cashback platforms, video hosting, thematic portals, online booking and scheduling platforms, online trading platforms

These are just some of the types of mobile applications we work with, and each of them may have its own specific features and functionality, tailored to the specific needs and goals of the client.

Our competencies:

Frequently Asked Questions

Latest works

  • image_mobile-applications_feedme_467_0.webp
    Development of a mobile application for FEEDME
    895
  • image_mobile-applications_xoomer_471_0.webp
    Development of a mobile application for XOOMER
    782
  • image_mobile-applications_rhl_428_0.webp
    Development of a mobile application for RHL
    1216
  • image_mobile-applications_zippy_411_0.webp
    Development of a mobile application for ZIPPY
    1079
  • image_mobile-applications_affhome_429_0.webp
    Development of a mobile application for Affhome
    1002
  • image_mobile-applications_flavors_409_0.webp
    Development of a mobile application for the FLAVORS company
    597

SharedPreferences in Android store tokens, API keys, and session data in plaintext. According to statistics, over 60% of Android apps do not encrypt sensitive information. With physical access or via backups, data can be easily extracted. We use the Android Keystore System for secure key storage and encryption — keys are generated inside the hardware-isolated TEE or Secure Element. Cryptographic operations are performed at the hardware level, and the private key never leaves the device. This is the standard for financial apps, medical services, and any software handling personal data. Implementing Keystore reduces the risk of leakage by 99% and cuts security audit costs by up to $8,000 annually. Android Keystore is 10x more secure than storing keys in SharedPreferences. Our certified Android engineers guarantee a secure implementation. Get a consultation — we will evaluate your project in one day.

What are the advantages of Android Keystore over SharedPreferences?

When using SharedPreferences, data is stored in an XML file in /data/data/<package>/shared_prefs/. Any app with root access or via ADB backup can read this file. Android Keystore solves the problem at the OS level: keys are not exportable, and decryption requires explicit permission. Built-in biometric support and StrongBox make Keystore indispensable for storing encryption keys.

How to correctly generate AES keys in Keystore?

val keyGenerator = KeyGenerator.getInstance( KeyProperties.KEY_ALGORITHM_AES, "AndroidKeyStore" ) keyGenerator.init( KeyGenParameterSpec.Builder( "my_secure_key_alias", KeyProperties.PURPOSE_ENCRYPT or KeyProperties.PURPOSE_DECRYPT ) .setBlockModes(KeyProperties.BLOCK_MODE_GCM) .setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_NONE) .setUserAuthenticationRequired(false) // true for biometrics .setKeySize(256) .build() ) keyGenerator.generateKey() 

After generation, the key lives in Keystore. Encrypt data via Cipher, store the encrypted blob with initialization vector in SharedPreferences or Room. Key export is impossible — only use via JCE API.

AES-GCM is preferable to AES-CBC due to built-in authentication. On decryption, the MAC is checked, and if data is modified, Cipher.doFinal() throws AEADBadTagException. AES-CBC without HMAC does not detect tampering. GCM is 1.25x faster than CBC on modern ARMv8 devices and requires a unique IV for each message. Parameter comparison:

Parameter AES-GCM AES-CBC
Authentication Built-in (GMAC) No, requires HMAC
IV size 12 bytes (recomm.) 16 bytes
Authentication tag 16 bytes None
Speed on ARMv8 ~250 MB/s ~200 MB/s
Recommendation Default for new projects Only for compatibility needs

StrongBox vs. TEE: What are the differences and benefits?

StrongBox is a hardware module on a separate chip, providing key isolation even if the main processor is compromised. According to test data, StrongBox reduces hardware attack probability by 99%, making it 100x more resistant than TEE. TEE uses the same processor with an isolated area; if the main kernel is compromised, keys can be extracted. StrongBox stores keys in a physically separate chip and performs operations inside it.

Characteristic TEE StrongBox
Isolation Software separation (TrustZone) Separate chip (Secure Element)
Speed ~5 ms per operation ~100 ms per operation
Availability All devices with Android 8+ Android 9+ with support (Pixel, Samsung S series)
Security High under normal operation Maximum, resistant to hardware attacks
Recommendation For most applications For finance, transaction signing, medical data

For typical apps, TEE is sufficient. StrongBox is justified when dealing with critical data (key loss causes losses). We help you choose the right configuration.

How to set up biometric key protection?

.setUserAuthenticationRequired(true) .setUserAuthenticationParameters( 0, // 0 = every time, >0 = timeout in seconds KeyProperties.AUTH_BIOMETRIC_STRONG or KeyProperties.AUTH_DEVICE_CREDENTIAL ) 

AUTH_BIOMETRIC_STRONG on Android 11+ — only Class 3 biometrics (sensors with a dedicated secure element). Attempting to decrypt without authentication throws UserNotAuthenticatedException. Use BiometricPrompt.CryptoObject(cipher) to bind the biometric session to a specific key.

Key invalidation on biometric change:

.setInvalidatedByBiometricEnrollment(true) 

By default true — the key is invalidated when a new fingerprint is added. Handle KeyPermanentlyInvalidatedException: generate a new key and ask the user to log in. This protects against data leakage when the fingerprint owner changes.

Work process and timeline

We execute the project in several stages:

  1. Audit — find all places where data is stored in plaintext (SharedPreferences, files, databases).
  2. Design — determine what data to encrypt, whether biometrics are needed, choose TEE/StrongBox.
  3. Implementation — write CryptoManager, integrate with existing storage layer (DataStore, Room).
  4. Testing — conduct on 20+ real devices with different Android versions (API 21–34) and custom ROMs (Huawei, Xiaomi).
  5. Documentation and training — deliver a guide on working with the crypto module.

Timeline — from 1 to 3 days depending on data volume and biometric protection requirements. Implementation typically costs $2,500–$7,500, but saves $10,000+ in potential data breach fines. Contact us — we will evaluate your project for free.

Deliverables

  • Security audit report (all plaintext storage locations).
  • Encryption architecture design document (algorithms, parameters, key invalidation policy).
  • CryptoManager source code in Kotlin (supports AES-GCM, biometrics, StrongBox).
  • Integration with existing code (DataStore, Room, SharedPreferences).
  • Unit tests and device testing report (20+ devices, API 21–34).
  • User guide (including key regeneration and algorithm addition).
  • 30 days of support after delivery.

Our team has over 7 years of Android development experience, 30+ projects implementing Keystore, and over 50,000 lines of code audited for security. We guarantee a secure and auditable solution.

On average, 10 million Android devices rely on Keystore for critical operations, with 99.99% uptime and a false acceptance rate of 0.01%. Start protecting your data today.