Given that limitation, my solution is below: Database browser Regrettably, support for inheritance and polymorphism is still in the works. I was hoping with the release of Realm 1.0 this would no longer be necessary by utilizing the RealmModel interface. I created an interface describing my object, and then created a Realm wrapper in my android project that would extend RealmObject. Ultimately my objects existed in a Java library, and, with Realm being Android only, I had to implement a strange hack. I won't dive deep into the Repository pattern itself, but conceptually it allows you to easily change your data layer implementation for development, testing, and production. Best practices Repository PatternĪlthough Realm comes with some nice utilities / add-ons to help directly populate RecyclerView Adapters, MapViews, and search results, you should always decouple your data layer from your UI layer using the Repository pattern. This deletes my entire Realm DB whenever Realm detects a schema change and expects a schema migration. Realm gives us a little hack for this, which obviously should only be used for pre-published development purposes. Usually during schema changes I'd have to manually clear the app data. When developing my pre-published app the schema might change multiple times. This was a big plus for me to keep my code readable and maintainable. The query API is an easy to use fluent API, where most of my queries are 1 liners. Realm is installed with your application, whereas SQLite exists on the end user's device, and the SQLite version is only updated when the Android OS is updated. Using Realm allows you to decide what version of Realm to use in your app. ![]() Why I chose Realm for the DebugRank app Controlling the Realm version Realm already has awesome documentation describing how to integrate Realm which can be found at realm.io. This blog is not a study of how to integrate Realm, but more an exploration of why I chose to use it in the DebugRank app. The key thing about Realm is that it is not an ORM (Object Relational Mapping) built on top of SQLite, but rather it's own persistence engine. Realm is the newest kid on the block regarding mobile databases, as opposed to the older SQLite on Android.
0 Comments
Leave a Reply. |