Google Sep 2, 2020

Data Storage Best Practices with Jetpack

Article Summary

Florina Muntenescu and Rohit Sathyanarayana from Google reveal why SharedPreferences has been secretly blocking your UI thread and causing ANRs. Their solution? Jetpack DataStore, a complete reimagining of Android data storage.

The Android team introduces DataStore, a Kotlin coroutines and Flow-based replacement for SharedPreferences. The article breaks down two implementations (Proto and Preferences), compares them against legacy options, and provides migration guidance for existing apps.

Key Takeaways

Critical Insight

DataStore replaces SharedPreferences with a fully asynchronous, type-safe storage solution that eliminates UI thread blocking and provides transactional data consistency.

The article includes specific code examples showing how Proto DataStore's schema generation creates compile-time safety that Preferences DataStore can't match.

Recent from Google

Related Articles