delete

abstract fun delete(deleteable: Deleteable)

Delete objects from the underlying Realm.

RealmObject, RealmList, RealmQuery, RealmSingleQuery and RealmResults can be deleted this way.

NOTE: Only live objects can be deleted. Frozen objects must be resolved in the current context using MutableRealm.findLatest:

val frozenObj = realm.query<Sample>.first().find()
realm.write {
findLatest(frozenObject)?.let { delete(it) }
}

Parameters

the

RealmObject, RealmList, RealmQuery, RealmSingleQuery or RealmResults to delete.

Throws

if the object is invalid, frozen or not managed by Realm.


abstract fun delete(className: String)

Deletes all objects of the specified class from the Realm.

Parameters

className

the class whose objects should be removed.

Throws

if the class does not exist within the schema.