createObject

abstract fun createObject(type: String): DynamicMutableRealmObject

Adds and returns a new object of the specified class to the Realm.

All fields will have default values; "" for strings, 0 for integral types, etc. and null for nullable fields.

Return

the new object.

Parameters

type

the class name of the object to create.

Throws

if the class name is not part of the realm's schema or the class requires a primary key.

abstract fun createObject(type: String, primaryKey: Any?): DynamicMutableRealmObject

Adds and returns a new object of the specified class with the given primary key to the Realm.

All fields will have default values; "" for strings, 0 for integral types, etc. and null for nullable fields.

Return

the new object.

Parameters

type

the class name of the object to create.

primaryKey

the primary key value.

Throws

if the class name is not part of the realm's schema or the primary key is not of the correct type.