Skip to main content

Realm data is compatible with Android mobile devices. It uses very little disk space, realm file perform better than SQLite or JSON. Here are the features of Realm database:


  • Realm is light weight database designed for mobile devices.
  • Replacement for SQLITE in mobile devices
  • It is a kind of No-SQL database
  • Fully Object Oriented.
  • Mobile-first written in C++
  • Cross platform support

Given below are the advantages of Realm 

  • 10X faster than SQLite
  • Easy to use - no need of query knowledge
  • Auto casting as a particular type

Given below are some of the disadvantages of using Realm

  • Still under development. However, Android app developers can proceed with released stable versions
  • Concurrent issue not handled    
  • No null support
  • No auto increment IDs
  • No mapping support - no foreign key
  • Migration is difficult

Integrating data in Realm

  1. Configuration
  2. Initialization
  3. CRUD operations
  1. Configuration
    • Single Module support
      • add the following to your app build.gradle file
      • compile 'io.realm:realm-android:2.3.1’ in your dependency
    • Multiple module support
      • add the following to your Project build.gradle file
        classpath "io.realm:realm-gradle-plugin:2.3.1" in your dependency
      • add the following to your app build.gradle file
        apply plugin: 'realm-android'

    thats it RealM configured in your project.

  2. Initialization
    • Init the Realm in your Application class and its custom configuration
      public class MyApplication extends Application {
            public void onCreate() {
            RealmConfiguration realmConfiguration = new                             
    • If you want can add database encryption by using application keystore file.
  3. CRUD Operations.
    1. A class can act as a table - query is not needed.
      Class Dog extends RealmObject{
              String key = "abc";
              int key = 123;
                  private int sessionId;
      • All the fields inside the class act as a column.
      • The field with @PrimaryKey annotation act as primary key for the table.
      • The field with @Ignore annotation can not be considered as a column - this filed ignored and no column is created for the filed
    2. Creating Entry.
      1. prepare UNMANAGED entries - does not having default entry in the table.
        Dog dog = new Dog();
      2. prepare MANAGED entries - can have its default entry in the table
        Dog dog = realm.createObject(Dog.class);;
    3. inserting into db
      • Get a Realm instance for this thread
        Realm realm = Realm.getDefaultInstance();
      • Before doing any write operation we must call
      • Do your write operation after beginTransaction.
        // Persist unmanaged objects
        final Dog managedDog = realm.copyToRealm(dog);
        // Create managed objects directly
        Person person = realm.createObject(Person.class);
      • After your write operation commit your updates into corresponding table

Examples :

  • Write operation
    Dog dog = new Dog();
    final Dog insertedRow = realm.copyToRealm(dog); 
  • Update operation
    dog.setName(“another name”);
    final Dog insertedRow = realm.copyToRealmOrUpdate(dog); 
  • Read Operation
  • Read Operation with conditions
    realm.where(Book.class).equalTo("id", id).findFirst();
                    .contains("author", "an")
                    .contains("title", "re")
  • Delete Operation
    // remove a single object
        Dog dog;
  • Truncate operation

Got an Idea of Android App Development? What are you still waiting for? Contact us now and see the idea live soon. 

You should always keep a backup of all the data on your Android phone. What to do if your phone is lost or stolen?  How to secure all the important information including the messages, contacts, photos and other data? Stay calm and take a breather. Protect all your data and avoid that disastrous scenario. There are numerous ways to automatically back up and sync your data from your Android device. Five easy steps are listed here to access, share, and manage your files on the go.

1. Backup your data

Automatically backup all your folders from your computer to provide real-time access to your data on your Android device. You can easily restore your files to your Android device whenever you like.

2. Sync your files to your device

Synchronize all your files, photos, music, videos, bookmarks and contacts between Android phones and computer without any effort from Android app developers.

3. Offline access

It is relatively easy to access all your files and documents offline. View and edit your files across your devices and smoothly synchronize your changes in data when the files are turned on when you're back at the office or at home.

4. Secure file sharing

Choose specific team members to view your files and folders instantly from your Android device. Give restricted access to share unlimited number of folders to have complete control over file sharing. Post your files on social media such as Facebook or Twitter.

5. Schedule your file sync

Schedule your synchronization of the files and photos in your collection to run in a specific time to get things done easier and faster on the go.

Subscribe to Android developer

start with anubavam today

You have an idea we have engineers to convert your ideas into reality

Request Quote