Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/187.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何使用各种领域数据库?_Android_Database_Realm - Fatal编程技术网

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

Android 如何使用各种领域数据库?,android,database,realm,Android,Database,Realm,我需要使用4个领域数据库,以便在每个领域中保存4个不同的对象,我在编程和领域以及我的学习方面是新手,但我在领域文档中发现了这一点: RealmConfiguration myConfig=newrealmconfiguration.Builder() .name(“myrealm.realm”) .阴谋厌恶(2) .modules(新的MyCustomSchema()) .build() RealmConfiguration otherConfig=newrealmconfiguration.B

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

RealmConfiguration myConfig=newrealmconfiguration.Builder()
.name(“myrealm.realm”)
.阴谋厌恶(2)
.modules(新的MyCustomSchema())
.build()

RealmConfiguration otherConfig=newrealmconfiguration.Builder()
.name(“otherrealm.realm”)
.阴谋厌恶(5)
.modules(新的MyOtherSchema())
.build()

realmmyrealm=Realm.getInstance(myConfig);
Realm-otherRealm=Realm.getInstance(otherConfig)

我认为这段代码应该放在MyApplication类中,但是我不能设置一个
DefaultInstance
,所以在我的MainActivity中,我不能获取默认实例并像往常一样使用它,我需要获取具有我想要的配置的实例。
这是我第一次来这里,对我的错误和糟糕的英语很抱歉。谢谢大家。

您确定需要不同的数据库吗?您可能只需要一个数据库和不同的对象表。
需要使用我想要的配置来获取实例。
是的,这就是为什么这可能是解决方案,但我不知道该怎么做@ariochdivij666@EpicPandaForce但我需要在代码中看到它,并知道使用它的位置