Supported Types - Kotlin SDK
On this page
Realm Database supports the following field data types:
String
Byte
Char
Short
Int
MutableRealmInt
, which behaves like aLong
but also supportsincrement
anddecrement
methods that implement a conflict-free replicated data type. For more information, see MutableRealmInt.Long
Boolean
Double
Float
Decimal128
ObjectId
RealmInstant
Any
RealmObject
subclassRealmList<T>
, where T is any of the supported data types or a RealmObject. Lists ofRealmObject
cannot have null elements. All other types ofRealmList<T>
can be nullable (RealmList<T?>
).RealmSet<T>
, where T is any of the supported data types or a RealmObject. Sets ofRealmObject
cannot have null elements. All other types ofRealmSet<T>
can be nullable (RealmSet<T?>
).RealmUUID
BacklinksDelegate<T>
, a backlinks delegate used to define an inverse relationship between RealmObjects.
Note
Importing ObjectId in the Realm Kotlin SDK version 1.5.x or Higher
With the Realm Kotlin Kotlin version 1.5.0 you must import
ObjectId
from org.mongodb.kbson.ObjectId. If
you were using an older SDK version and wish to upgrade, replace your old
import statements as io.realm.kotlin.types.ObjectId
has been deprecated.
Realm Database stores all non-decimal numeric types as Long
values.
Similarly, Realm Database stores all decimal numeric types as Double
values.
Realm Database does not support fields with modifiers final
and
volatile
, though you can use fields with those modifiers if you
ignore them. If you choose to provide custom
constructors, you must declare a public constructor with no arguments.
Updating Strings and Byte Arrays
Since Realm Database operates on fields as a whole, it's not possible to directly update individual elements of strings or byte arrays. Instead, you'll need to read the whole field, make your modification to individual elements, and then write the entire field back again in a transaction block.