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 lifecycle 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 and looked at how we can use other data streams with ViewModels
and compare those with LiveData
.
We then moved on to Room to show how we can persist data with minimal effort and without much 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.
The activity we completed in this chapter serves as an example of what direction Android apps are heading in. However, this was not a complete example due...