When it comes to storing application data in a database on Android, there’s not much of a choice the developer has. First of all, there is SQLite as the only officially recommended solution in Android framework. On top of SQLite, there is a number of ORM (Object-relational mapping) frameworks available which aim at allowing developer to work directly with objects when storing and reading data from a database. SQLite is however sometimes not so easy to use and there are some drawbacks due to not being designed specificaly for mobile devices. Luckily, there is another kind of database gaining on popularity lately — the Android Realm database.
In my last post, I’ve introduced the Android data binding support library which helps to get rid of unnecessary boiler-plate code related to view-model binding. In this post, I’d like to introduce you to the Android MVVM pattern (Model-View-ViewModel) which builds upon data binding functionality and helps to keep the architecture design of your applications clean and its parts clearly decoupled.
Every Android developer knows the usual tiresome way of binding their application logic with layouts. Tens or even hundreds of boilerplate code lines containing the findViewById methods and never-ending manual updating of view properties based on changes in data. Thankfully, Android data binding support library comes to help automate things and simplify your code.