And add the dependencies and plugins everything is fine but when I put this
private void setUpRealmConfig(){
RealmConfiguration config = new RealmConfiguration.Builder(getApplicationContext()).deleteRealmIfMigrationNeeded().build();
Realm.setDefaultConfiguration(config);
}
in the part of = RealmConfiguration.Builder. I get this error:
Builder(android.content.Context)' is not public in 'io.realm.RealmConfiguration.Builder'. Cannot be accessed from outside package
and I do not know what to do.
In Realm, we don't pass any parameter to Builder.To set Realm configuration setting we simply call Builder initialization.
For eg:-
Realm.init(getApplicationContext());
RealmConfiguration realmConfiguration = new RealmConfiguration.Builder()
.name(Realm.DEFAULT_REALM_NAME)
.schemaVersion(0)
.deleteRealmIfMigrationNeeded()
.build();
Realm.setDefaultConfiguration(realmConfiguration);
If I'm not mistaken, since version 2 of Realm you need pass context to Ream by call init()
method.
init()
of Realmprivate void setUpRealmConfig(){
// initialize Realm
Realm.init(getApplicationContext());
// create your Realm configuration
RealmConfiguration config = new RealmConfiguration.
Builder().
deleteRealmIfMigrationNeeded().
build();
Realm.setDefaultConfiguration(config);
}
It looks like that constructor is deprecated. Try using this one instead:
RealmConfiguration config = new RealmConfiguration.Builder().deleteRealmIfMigrationNeeded().build();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With