delete
Delete objects from the underlying Realm.
RealmObject, EmbeddedRealmObject, 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 by using MutableRealm.findLatest:
val frozenObj = realm.query<Sample>.first().find()
realm.write {
findLatest(frozenObject)?.let { delete(it) }
}
Content copied to clipboard
Parameters
deleteable
the RealmObject, EmbeddedRealmObject, RealmList, RealmQuery, RealmSingleQuery or RealmResults to delete.
Throws
if the object is invalid, frozen or not managed by Realm.
Deletes all objects of the specified class from the Realm.
Parameters
schemaClass
the class whose objects should be removed.
Throws
if the class does not exist within the schema.