Docs Menu
Docs Home
/ /
Atlas Device SDKs
/ / /

Class RealmSchema

On this page

  • io.realm
  • Method Summary
  • Inherited Methods
  • Method Detail
  • contains
  • create
  • createKeyPathMapping
  • createWithPrimaryKeyField
  • get
  • getAll
  • getColumnInfo
  • remove
  • rename
java.lang.Object
io.realm.RealmSchema

Class for interacting with the Realm schema. This makes it possible to inspect, add, delete and change the classes in the Realm.:ref:Realm.getSchema() <io_realm_Realm_getSchema__> returns an immutable RealmSchema which can only be used for inspecting. Use DynamicRealm.getSchema() to get a mutable schema.

All changes must happen inside a write transaction for the particular Realm.

Tip

See also:

  • RealmMigration

Modifier and Type
Method and Description
public boolean
String className
)

Checks if a given class already exists in the schema.

public abstract RealmObjectSchema
String className
)

Adds a new class to the Realm.

public void

Create the underlying keypath mapping.

public abstract RealmObjectSchema
String className,
String primaryKeyFieldName,
)

Adds a new class to the Realm with a primary key field defined.

public abstract RealmObjectSchema
get (
String className
)

Returns the RealmObjectSchema for a given class.

public abstract Set

Returns the RealmObjectSchema s for all RealmObject classes that can be saved in this Realm.

protected final ColumnInfo
String className
)
public abstract void
String className
)

Removes a class from the Realm.

public abstract RealmObjectSchema
String oldClassName,
String newClassName
)

Renames a class already in the Realm.

  • Methods inherited from class java.lang.Object : getClass , hashCode , equals , clone , toString , notify , notifyAll , wait , wait , wait , finalize

public boolean contains (
String className
)

Checks if a given class already exists in the schema.

Parameters

  • className - class name to check.

Returns

true if the class already exists. false otherwise.

public abstract RealmObjectSchema create (
String className
)

Adds a new class to the Realm.

Parameters

  • className - name of the class.

Returns

a Realm schema object for that class.

Throws

public void createKeyPathMapping ()

Create the underlying keypath mapping. Should only be called by typed Realms.
String className,
String primaryKeyFieldName,
)

Adds a new class to the Realm with a primary key field defined.

Parameters

  • className - name of the class.

  • primaryKeyFieldName - name of the primary key field.

  • fieldType - type of field to add. Only byte , short , int , long and their boxed types or the String is supported.

  • attributes - set of attributes for this field. This method implicitly adds FieldAttribute.PRIMARY_KEY and FieldAttribute.INDEXED attributes to the field.

Returns

a Realm schema object for that class.

Throws

public abstract RealmObjectSchema get (
String className
)

Returns the RealmObjectSchema for a given class. If this RealmSchema is immutable, an immutable RealmObjectSchema will be returned. Otherwise, it returns a mutable RealmObjectSchema .

Parameters

  • className - name of the class

Returns

schema object for that class or null if the class doesn't exists.

public abstract Set getAll ()

Returns the RealmObjectSchema s for all RealmObject classes that can be saved in this Realm. If this RealmSchema is immutable, an immutable RealmObjectSchema set will be returned. Otherwise, it returns an mutable RealmObjectSchema set.

Returns

the set of all classes in this Realm or no RealmObject classes can be saved in the Realm.

protected final ColumnInfo getColumnInfo (
String className
)
public abstract void remove (
String className
)

Removes a class from the Realm. All data will be removed. Removing a class while other classes point to it will throw an IllegalStateException . Removes those classes or fields first.

Parameters

  • className - name of the class to remove.

Throws

public abstract RealmObjectSchema rename (
String oldClassName,
String newClassName
)

Renames a class already in the Realm.

Parameters

  • oldClassName - old class name.

  • newClassName - new class name.

Returns

a schema object for renamed class.

Throws

Back

RealmResults