2

I have some realmObject(my data model) in my android app and some Sync Realm for example:

realm_url1 = "realm://myserver:9080/~/setting contain some user setting realmObject

realm_url2 = "realm://myserver:9080/~/app contain some app realmObject

How i can set what object create in what realm_url? because all of my realmObject has created in all realm_url. I getInstance to __permission realm to read user permission but all of my realm object create there and __permission not work properly again and i can't restore it to back. Please get me know can separate object is realms.

Saeed
  • 101
  • 1
  • 1
  • 12

1 Answers1

1

If you want to create a separate schema for each Realm, you can do so by using the @RealmModule annotation. You can see how to use it here: https://realm.io/docs/java/latest/#schemas

// Create the module
@RealmModule(classes = { Person.class, Dog.class })
public class MyModule {
}

// Set the module in the RealmConfiguration to allow only classes defined by the module.
SyncConfiguration config = new SyncConfiguration.Builder(user, url)
  .modules(new MyModule())
  .build();

// It is possible to combine multiple modules to one schema.
SyncConfiguration config = new SyncConfiguration.Builder(user, url)
  .modules(new MyModule(), new MyOtherModule())
  .build();
Christian Melchior
  • 19,978
  • 5
  • 62
  • 53
  • Hi @Christian Melchior thank's a lot this is mean all other class not create? or this is mean this class are created? – Saeed Jun 16 '17 at 12:42