Things I Think Are Cool is a blog series where I talk about things I have found interesting and helpful. They can be time savers, productivity tools, podcasts, books, products, or even people.

Inevitably there will come a time in your app's life that it will need to save data. And there are several ways you can accomplish that goal (in fact, I wrote a whole series of posts on how you can do just that).

But like any important decision in life, there are a multitude of options - and some are a better fit than others.

You're not going to want to cache an entire catalog of products in the app's settings, for instance.

A new option burst upon the Xamarin scene in the spring of 2016 for data persistence (and it doesn't involve SQLite) - and it's pretty cool ... and this week's topic ... Realm!

Why It's Cool

Realm Mobile Database is a database engine that was built for mobile devices. It doesn't depend on SQLite under the covers ... it has its own custom engine, designed for mobile, which means ... it's smoking fast! It's optimized for performance.

Another great thing about Realm is the way you access the data. The database itself is called a Realm. You use "regular" objects that inherit from RealmObject. So the "table", in the relational database world, would be equatable to the class which inherits from RealmObject and the "columns" of the table are the class's properties.

But Realm is not an ORM ... obviously there are objects - but there's no relational mapping going on... the RealmObject is the table, so to speak. And that's cool for a couple of reasons.

First - once that RealmObject is either connected to, or retrieved from, a Realm - it's live updating! Meaning, if that particular object you are holding gets updated elsewhere in the database, or Realm, the copy you have will be updated!

The same goes for collections of objects pulled out of a Realm. If another object gets added to the Realm - that collection will be updated!

When pulling data out of a Realm, it comes out as an IQueryable ... which means Linq!! And all the goodness that goes along with that.

Also, RealmObject implements INotifyPropertyChanged ... meaning if one is data bound to your UI through a VM - it's pretty easy to get it to save back to the Realm (at least a lot less typing to set properties).

And ... Realm is open source - and the people behind Realm are responsive to issues on GitHub.

How To Get It

It's available as a NuGet package.

And also up on GitHub.

That's Cool!