如何使用各种领域数据库?

时间:2018-05-14 20:38:21

标签: android database realm

我需要使用4个领域数据库,以便在每个数据库中保存4个不同的对象,我在编程和领域以及即时学习方面都是新的,但我在领域文档中发现了这一点:

RealmConfiguration myConfig = new RealmConfiguration.Builder() .name("myrealm.realm") .schemaVersion(2) .modules(new MyCustomSchema()) .build();

RealmConfiguration otherConfig = new RealmConfiguration.Builder() .name("otherrealm.realm") .schemaVersion(5) .modules(new MyOtherSchema()) .build();

Realm myRealm = Realm.getInstance(myConfig); Realm otherRealm = Realm.getInstance(otherConfig);

我认为这段代码应该放在MyApplicacion类中,但我不能设置DefaultInstance所以在我的MainActivity中我无法获取默认实例并一如既往地使用它,我需要使用conf获取实例我想要。 这是我第一次在stackoverflow中为我的错误和糟糕的英语感到抱歉。谢谢大家。

0 个答案:

没有答案