Summary
In this chapter, we analyzed the building blocks required to build a maintainable application. We also looked into one of the most common issues that developers come across when using the Android Framework, which is maintaining the states of objects during life cycle changes.
We started by analyzing ViewModels
and how they solve the issue of holding data during orientation changes. We added LiveData
to ViewModels
to show how the two complement each other.
We then moved on to Room to show how we can persist data with minimal effort and without a lot of SQLite boilerplate code. We also explored one-to-many and many-to-many relationships, as well as how to migrate data and break down complex objects into primitives for storage.
After that, we reinvented the Lifecycle
wheel in order to show how LifecycleOwners
and LifecycleObservers
interact.
We also built our first repository, which we will expand upon in the following chapters when other data sources are added into...