Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Gotta Persist 'Em All: Realm as Replacement for...

Gotta Persist 'Em All: Realm as Replacement for SQLite

Realm is a new player on mobile database scene, and acts as a replacement for SQLite on Android and Core Data on iOS by providing a database and an easy-to-use object-relational mapping-like interface. Learn how to use it in your own projects and how it compares to working with SQLite in a beginner-friendly sample app with Pokémon.

Siena Aguayo

May 05, 2016
Tweet

More Decks by Siena Aguayo

Other Decks in Technology

Transcript

  1. Overview • What Realm Is • Pros and cons •

    Compare and contrast with SQLite • What Realm Isn’t
  2. • “embedded mobile database” Realm • Core is written in

    C++ • Available for Android and iOS • Second most-deployed mobile database in the world
  3. Pros for Realm • Very responsive team • Easy to

    use • Convenient for creating and storing data on the fly • Object conversion handled for you • Faster than SQLite
  4. Cons for Realm • Have to create with Java on

    the device • Still under active development • Not a lot of content online • No importing • Can’t access objects across threads
  5. Missing Features • Auto-incrementing ids • Compound primary keys •

    Testing with Robolectric • Map<K, V> support
  6. An ORM or not? SQLite >> pragma table_info(pokemon) 0|id|INTEGER|1||1 1|identifier|VARCHAR(79)|1||0

    2|height|INTEGER|1||0 3|weight|INTEGER|1||0 Java public class Pokemon { private int id; private String identifier; private int height; private int weight; // constructor(s), // getters, setters } Typical ORM usage
  7. Shout-Out to Other ORMs • greenDAO • Active Android •

    Sugar ORM • ORMLite (Java) • Cupboard Michael Pardo’s Android Data talk
  8. Acknowledgments • Realm: http://realm.io/ • SQLite db from veekun’s Pokémon

    repo: https://github.com/veekun/pokedex • Official Pokémon art by Ken Sugimori • Christian Melchior for feedback