

The productivity gain from replacing SQLite with Realm database starts with some simple steps. Here is a screenshot of what the app will look like. This will be a simple quote app that displays a list of motivational quotes from different authors. To understand Realm database, let us create a simple demo app that demonstrates the core concepts of Realm database. For Java object to become Realm managed, the class must either extend RealmObject or implement RealmModel interface. Realm managed objects are your equivalent of SQLite tables. It is kind of like a what-you-see-is-what-is-saved workflow - changes to the object in the user interface are automatically saved to the database if the object is a Realm managed object. Another way to look at it is that Realms are databases that do not require a separate mapping from Java objects to the persisted version on the disk. Realms can map different kinds of objects to one file on disk. At the center of Realm database is this thing called Realm, which is equivalent to a traditional database. Realm database works by saving Java objects directly to disk as objects instead of first mapping them to another data type like SQLite does. While SQLite will continue to have its place in Android development, I believe that Realm database saves developers a lot of time and most new Android development projects should use Realm for data persistence instead of SQLite to increase developer productivity. Realm is a "better database: faster, simpler, and Java-native." The words "better, faster, and simpler" imply a comparison - the comparison here is between Relam and SQLite for Android. According to the official Realm description, Realm database is a mobile first database built from the ground-up to run directly inside phones, tablets, and wearable.
