- Introduced the new androidx.datastore:datastore-tink artifact providing encryption support for DataStore using the Tink library
- Introduced the AeadSerializer, a Serializer<T> wrapper that uses Tink's Authenticated Encryption with Associated Data (AEAD) to encrypt and decrypt data, available on JVM and Android targets
- Introduced DataStore.Builder<T> as the scalable alternative to DataStoreFactory
- Added setCorruptionHandler to DataStore.Builder, allowing users to provide their own corruption handling logic
- The DataStore.Builder API requires initialization with a CoroutineContext instead of a CoroutineScope to improve structured concurrency and let callers define execution behavior without binding DataStore to the caller's scope lifecycle
From AndroidX DataStore
Encryption Support: Introduced the new androidx.datastore:datastore-tink artifact which provides support for encryption of your datastore using the Tink library. This module introduces the AeadSerializer, which is a new wrapper class that implements Serializer and uses Tink's Authenticated Encryption with Associated Data (AEAD) to encrypt and decrypt data. The AeadSerializer is available to use in JVM and Android target platforms. New DataStore Builder API: Introduced DataStore.Builder as the scalable alternative to DataStoreFactory. With this new API, users now have a way to provide their own corruption logic via setCorruptionHandler. In addition, the Builder API requires that a DataStore is initialized using a CoroutineContext instead of a CoroutineScope, an improvement for structured concurrency, as it allows callers to define execution behavior (like specific Dispatchers) without forcing DataStore to inappropriately manage or be bound by the lifecycle of the caller's scope. Note: We recommend all users to migrate from DataStoreFactory to the new DataStore.Builder APIs. By requiring a CoroutineContext instead of a CoroutineScope, the API enforces better structured concurrency. This ensures DataStore operations are not bound to short-lived UI lifecycles (e.g., viewModelScope), preventing premature cancellation and potential data loss. Warning: Ensure that the CoroutineContext provided to the Builder has a Job, and that it is application-scoped. If the context is canceled, DataStore's internal operations will be terminated prematurely. Introduced the new androidx.datastore:datastore-tink artifact for DataStore encryption support. Introduced DataStore.Builder as the modern, scalable alternative to DataStoreFactory.