Realm the Mobile Database

As Android developers, everyone knows the database SQLite for storing information on devices. But SQLite is suitable for storing JSON or Java objects. When we are receiving JSON data from Rest API's. Sometimes Working with SQLite makes code difficult to understand, and the writing of some SQL queries can take too much time. Using ORM partially solves some problems, but today we have an alternative way, known as Realm. Realm allows us to easily store Java Objects,retreive and modify Java Objects.
Why we need to say No to ORM:
A lot of what you would call “database libraries” are simply that — third party libraries using a particular storage engine that provide a modern/functional/different (pick your favorite) approach to accessing an existing data layer.
You could use a Swift or Java library to access your SQLite storage in a more modern way by using generics and structs. But the storage engine that’s doing all of the reading and writing to disk is still SQLite.
Plus, that third-party library you use will still need to convert your native data structures to some intermediate format, execute behind-the-scenes SQL queries, and convert your data to SQL table rows.
If you are using a full-fledged ORM, you will almost always have numerous operations running in the background. An ORM will continuously convert your objects to intermediate format and run SQL queries to talk to a SQLite file. Any time you access a related object to the object you’re working with - the ORM will convert this to a JOIN SQL query, execute that query on a lookup table, and find matching records in another table where those related objects are stored.
This is a lot of work for simple data access. Not only does it take up CPU cycles and disk time, but it can become slow very quickly. That means you have to take that work off your main thread and introduce proper threading techniques, and now your code is getting rather complicated, just to get your data.
Why to choose Realm?
Realm is not an ORM, and is not built on top of SQLite. Instead They’ve built a full database for mobile app developers
It’s an easy mistake to think that Realm is built on top of an existing technology, or that it’s just a modern rewrite of another library...(Read More)

Comments