No RealmDictionary in Kotlin SDK

We’re using the Kotlin SDK in our Android app and in MongoDB we have a field that is a map/dictionary of Strings to Integer values. It has the following bson definition:

"someField": {
      "additionalProperties": {
        "bsonType": "int"
      "bsonType": "object"

In the old Java SDK, there was a class called RealmDictionary that could represent such a data structure. Unfortunately, that doesn’t exist in the Kotlin SDK anymore.
What is the suggested way of representing this when using the Kotlin SDK?

Thanks for your help in advance.

1 Like

What version of the SDK are you using?

We’re using 10.10.0 on our android/kotlin app and I’m using RealmDictionary in a bunch of places.

import io.realm.RealmDictionary


open class DetailInfo() : RealmObject() {
    var socialIds: RealmDictionary<String> = RealmDictionary()

Hi Alex,

I think you might be referring to the Java SDK form Realm. MongoDB has actually 2 different SDKs for accessing realm on the JVM:

The Java SDK is at version 10.11.1 and the Kotlin SDK is at version 1.1.0.
Due to some limitations of the Java SDK when it comes to multi-module setups we have to use the Kotlin SDK in our project. And that doesn’t have the RealmDictionary class anymore.
So I’m looking for ways to use maps/dictionaries when using the Kotlin SDK.

Well well well. TIL.

You’re right, we’re using realm-java. I feel like we should move to the Kotlin library, but if it doesn’t have RealmDictionary, that’ll prevent us from doing so for now.

Looking more. Frozen objects might change the entirety of how we use realm, so yeah, there’s that too. Anyway thanks for the insight.