0

I am getting an io.realm.exceptions.RealmError for some users in my android application.

public Realm getRealm(){
    RealmConfiguration config = new RealmConfiguration.Builder()
            .schemaVersion(0)
            .deleteRealmIfMigrationNeeded()   
            .build();
    return Realm.getInstance(config); //getting error at this line
}

realm version: 3.7.2
Please tell me how to fix that.

Crash logs

Asad Mahmood
  • 188
  • 1
  • 10

1 Answers1

0

The way i coded Realm was by initializing the default instance in the application using the following code.

    Realm.init(this);
    RealmConfiguration realmConfiguration = new RealmConfiguration.Builder()
            .name(REALM_DB_NAME)
            .schemaVersion(0)
            .deleteRealmIfMigrationNeeded()
            .build();
    Realm.setDefaultConfiguration(realmConfiguration);

An everytime i wanted to get an instance of realm i would use the following command.

Realm  realm = Realm.getDefaultInstance();
Jude Fernandes
  • 7,437
  • 11
  • 53
  • 90