CushyStorage is a unified, hardware-secured wrapper for Android local storage. With this article, I am happy to continue the D2D (Developer-to-Developer) series, where I share specialized tools designed to help engineers make their work more effective, robust, and straightforward.
This series began with the Pushes Test Project — a utility created to help developers model and program in-app notifications for testing purposes. Today, I am excited to introduce the second tool in this suite: CushyStorage.
It was built to fill the gaps in the existing Android framework by bringing standard SharedPreferences and reactive DataStore together under one intuitive API. Crucially, it addresses a major gap in modern development: the legacy EncryptedSharedPreferences is deprecated, leaving developers without a simple, built-in way to save encrypted preferences. CushyStorage covers this important feature by providing industrial-grade AES-GCM security that is just as easy to use as a standard string save.
I invite you to explore this library, try the interactive demo on the Play Store, and consider using it to simplify your own projects. If this tool helps you in your development work, please show your support by clapping for this article, following me, and subscribing for future updates. Your support is what keeps this D2D initiative growing!

Why Saving a String is Still Hard
In 2026, the Android local persistence landscape remains surprisingly fragmented. Developers are often forced to choose between the legacy SharedPreferences (fast but blocking), Jetpack DataStore (modern but boilerplate-heavy), and the deprecated EncryptedSharedPreferences.
Why should we have to write completely different architectures just because one string is a “username” and the other is a “secret token”?
Enter CushyStorage: A unified, Developer-to-Developer (D2D) library designed to provide a single, “flat” API for every persistence use case.
Getting Started: Integration & Initialization
To bring CushyStorage into your project, simply add the dependency to your build.gradle.kts file. The library is officially available on Maven Central:
dependencies {
implementation("pro.udeedit.devtools:cushystorage:1.0.3")
}Once the dependency is synchronized, you need to initialize the library once. The most robust approach is to do this in your Application class, ensuring that the storage engines are prepared globally before any Activity or ViewModel attempts to access them.
Option 1: The “Cushy” Way (Recommended)
For 99% of use cases, the default initialization is perfect. It automatically sets up AES-GCM (256-bit) security with industry-standard parameters.
/**
* Initialize CushyStorage with default settings.
* This sets up Simple, Reactive, and Secure (AES-GCM) storage layers.
*/
class MyApp : Application() {
override fun onCreate() {
super.onCreate()
CushyStorage.init(this)
}
}Option 2: The “Power User” Way (Custom Security)
For projects with specific security audits or legacy requirements, CushyStorage allows you to define your own encryption strength using the CushyConfig object. You can adjust the AES mode, Key size, Tag bits, and IV size:
/**
* Initialize with custom security settings if needed
*/
class MyApp : Application() {
override fun onCreate() {
super.onCreate()
val customConfig = CushyConfig(
keySize = 256,
tagSizeBits = 128,
ivSizeBytes = 12
)
CushyStorage.init(this, customConfig)
}
}The Architecture: Three Layers of Comfort
CushyStorage is built on a modular “engine” architecture, allowing you to choose the level of speed, reactivity, and security you need without having to learn a new API for each:
1. Standard Storage (Simple)
Built on traditional SharedPreferences. This layer is optimized for fast, synchronous access to non-sensitive data like UI states or simple app settings.
// Simple, synchronous save
CushyStorage.saveString(CushyKeys.KEY_USERNAME, "Alex_Dev")
// Direct retrieval with a fallback default
val username = CushyStorage.getString(CushyKeys.KEY_USERNAME, "Guest")2. Reactive Storage (Simple)
Leveraging Jetpack DataStore. It provides asynchronous, thread-safe Flow updates, making it the perfect partner for Jetpack Compose UIs that need to stay in sync with the disk in real-time.
// Observing a live counter directly in a Composable
val reactiveCounter by CushyStorage.observeString(CushyKeys.KEY_COUNTER, "0")
.collectAsStateWithLifecycle(initialValue = "0")3. Secure Storage (Encrypted)
The powerhouse of the library. It combines AES-GCM (256-bit) encryption with hardware-backed Android KeyStore protection, providing a robust replacement for the deprecated EncryptedSharedPreferences. By utilizing the device’s physical security chips (TEE/SE), the cryptographic keys remain isolated and non-extractable.
Despite the complex security under the hood, the API remains identical to the simple layer:
// Secure, asynchronous encryption and storage
scope.launch {
CushyStorage.saveStringEncrypted(CushyKeys.KEY_SECURE_TOKEN, "secret_api_key_123")
}
// Decrypted retrieval with a single suspend call
scope.launch {
val token = CushyStorage.getStringEncrypted(CushyKeys.KEY_SECURE_TOKEN)
}The “Reactive + Secure” Power Layer
One of the most significant challenges in modern Android development is managing sensitive data in a reactive UI. Traditionally, displaying an encrypted value that updates in real-time requires manual observation of a flow, catching the encrypted string, and manually triggering a Cipher to decrypt it before every UI emission.
CushyStorage eliminates this boilerplate with the observeStringEncrypted() function.
// The "Power Layer": Automated background decryption + DataStore Flow
val secureAlias by CushyStorage.observeStringEncrypted(CushyKeys.KEY_SECURE_ALIAS)
.collectAsStateWithLifecycle(initialValue = "No Alias Set")The library handles the complex background decryption and flow management automatically. To see this magic in action, you can download the CushyStorage Library Demo from the [Google Play Store]. In the demo app, you will observe firsthand how your UI effortlessly stays in sync with a clean, plain-text stream, while the hardware-secured engine works silently under the hood.
For a deeper dive into the architecture and to explore many other practical use cases, I invite you to visit the CushyStorage GitHub Repository. There, you can examine the full source code and see exactly how we turned complex security into a “cushy” developer experience.
Join the Journey 
Building tools that simplify the lives of other developers is my passion. If CushyStorage brings a bit of comfort to your workflow, I would love to hear from you!
Designed and built for developers by developers. Focus on your code — we’ll handle the storage.
UDeedIt Pro: DevTools Suite
