io.realm
Enclosing class:
RealmConfiguration.Builder used to construct instances of a RealmConfiguration in a fluent manner.
Constructores
Constructor and Description |
|---|
Builder () Crea una instancia del constructor para RealmConfiguration. |
Resumen del método
Modificador y Tipo | Método y descripción |
|---|---|
public final RealmConfiguration.Builder | |
public RealmConfiguration.Builder | Configura si un RealmQuery puede iniciarse desde el hilo Interfaz de Usuario o no. |
public RealmConfiguration.Builder | Sets whether or not calls to Realm.executeTransaction are allowed from the UI thread. |
public RealmConfiguration.Builder | |
public RealmConfiguration | build () Crea la RealmConfiguration basada en los parámetros del generador. |
public RealmConfiguration.Builder | Sets this to determine if the Realm file should be compacted before returned to the user. |
public RealmConfiguration.Builder | Si estableces esta opción, Realm compactará el archivo Realm si este ha crecido demasiado y se puede recuperar una cantidad significativa de espacio. |
public RealmConfiguration.Builder | Establecer esto cambiará el comportamiento de manejo de las excepciones de migración. |
public RealmConfiguration.Builder | |
public RealmConfiguration.Builder | Sets the 64 byte key used to encrypt and decrypt the Realm file. |
public RealmConfiguration.Builder | Establece la FlowFactory utilizada para crear flujos de corrutinas a partir de objetos Realm. |
public RealmConfiguration.Builder | inMemory () Establecer esto creará un Realm en memoria en lugar de guardarlo en el disco. |
public RealmConfiguration.Builder | Sets the initial data in io.realm.Realm . |
public RealmConfiguration.Builder | Establece el número máximo de versiones activas en el archivo Realm antes de que se lance una IllegalStateException al intentar guardar más datos. |
public RealmConfiguration.Builder | Define io.realm.RealmMigration que se debe ejecutar si se requiere una migración. |
public RealmConfiguration.Builder | Replaces the existing module(s) with one or more RealmModule s. |
public RealmConfiguration.Builder | |
public RealmConfiguration.Builder | readOnly () Configurar esto hará que el Realm se vuelva de solo lectura y todas las transacciones de escritura realizadas contra este Realm fallarán con una IllegalStateException . |
public RealmConfiguration.Builder | Sets the RxObservableFactory used to create Rx Observables from Realm objects. |
public RealmConfiguration.Builder | Establece la versión de esquema del Realm. |
Inherited Methods
Métodos heredados de la clase java.lang.Object:
getClass,hashCode,equals,clone,toString,notify,notifyAll,wait,wait,wait,finalize
Constructor Detail
public Builder () |
|---|
Crea una instancia del Builder para el RealmConfiguration. Esto utilizará el propio directorio interno de la aplicación para almacenar el archivo Realm. Esto no requiere permisos adicionales. La ubicación por defecto es |
Detalle del método
addModule
FIXME: Temporary visible DEBUG method. Will add a module unconditionally. Adds a module to already defined modules. |
allowQueriesOnUiThread
Configura si un RealmQuery puede iniciarse desde el hilo Interfaz de Usuario o no. By default Realm allows queries on the main thread. However, by doing so your application may experience a drop of frames or even ANRs. We recommend diverting queries to non-UI threads or, alternatively, using RealmQuery.findAllAsync() or RealmQuery.findFirstAsync() . |
allowWritesOnUiThread
Sets whether or not calls to Realm.executeTransaction are allowed from the UI thread. WARNING: Realm does not allow synchronous transactions to be run on the main thread unless users explicitly opt in with this method. We recommend diverting calls to |
assetFile
Copies the Realm file from the given asset file path.When opening the Realm for the first time, instead of creating an empty file, the Realm file will be copied from the provided asset file and used instead. Esto no se puede combinar con deleteRealmIfMigrationNeeded() ya que hacerlo solo provocaría que se borre el archivo copiado. ADVERTENCIA: Esto podría ser una operación prolongada y, lo ideal, es realizarla en un hilo en segundo plano. Parámetros
Throws
|
compilar
public RealmConfiguration build () |
|---|
Crea la RealmConfiguration basada en los parámetros del generador. Devuelve the created RealmConfiguration . |
compactOnLaunch
Sets this to determine if the Realm file should be compacted before returned to the user. It is passed the total file size (data + free space) and the bytes used by data in the file. Parámetros
|
public RealmConfiguration.Builder compactOnLaunch () |
|---|
Setting this will cause Realm to compact the Realm file if the Realm file has grown too large and a significant amount of space can be recovered. See DefaultCompactOnLaunchCallback for details. |
deleteRealmIfMigrationNeeded
Al configurar estos parámetros, se modifica el comportamiento de cómo se gestionan las excepciones de migración. En lugar de lanzar una io.realm.exceptions.RealmMigrationNeededException, el Realm en disco se borrará y recreará con el nuevo esquema de Realm. This cannot be configured to have an asset file at the same time by calling assetFile(String) as the provided asset file will be deleted in migrations. WARNING! This will result in loss of data. Throws
|
directorio
Specifies the directory where the Realm file will be saved. The default value is Parámetros
Throws
|
encryptionKey
Establece la clave de 64 bytes utilizada para cifrar y descifrar el archivo Realm. Establece la clave de bytes io.realm.Realm#ENCRYPTION_KEY_LENGTH usada para cifrar y descifrar el archivo Realm. |
flowFactory
Sets the FlowFactory used to create coroutines Flows from Realm objects. The default factory is RealmFlowFactory . Parámetros
|
En memoria
public RealmConfiguration.Builder inMemory () |
|---|
Setting this will create an in-memory Realm instead of saving it to disk. In-memory Realms might still use disk space if memory is running low, but all files created by an in-memory Realm will be deleted when the Realm is closed.Note that because in-memory Realms are not persisted, you must be sure to hold on to at least one non-closed reference to the in-memory Realm object with the specific name as long as you want the data to last. |
initialData
Sets the initial data in io.realm.Realm . This transaction will be executed only for the first time when database file is created or while migrating the data when Builder.deleteRealmIfMigrationNeeded() is set. Parámetros
|
maxNumberOfActiveVersions
Establece el número máximo de versiones activas en el archivo Realm antes de que se lance una IllegalStateException al intentar guardar más datos. Realm is capable of concurrently handling many different versions of Realm objects. This can e.g. happen if you have a Realm open on many different threads or are freezing objects while data is being written to the file. Under normal circumstances this is not a problem, but if the number of active versions grow too large, it will have a negative effect on the filesize on disk. Setting this parameters can therefore be used to prevent uses of Realm that can result in very large Realms. Parámetros
Tip |
migration
Sets the io.realm.RealmMigration to be run if a migration is needed. If this migration fails to upgrade the on-disc schema to the runtime schema, a io.realm.exceptions.RealmMigrationNeededException will be thrown. |
modules
Replaces the existing module(s) with one or more RealmModule s. Using this method will replace the current schema for this Realm with the schema defined by the provided modules. A reference to the default Realm module containing all Realm classes in the project (but not dependencies), can be found using Realm.getDefaultModule() . Combining the schema from the app project and a library dependency is thus done using the following code:
Parámetros
Throws
|
Nombre
Establece el nombre del archivo para el archivo Realm. |
Solo lectura
public RealmConfiguration.Builder readOnly () |
|---|
Configurar esto hará que el Realm se vuelva de solo lectura y todas las transacciones de escritura realizadas contra este Realm fallarán con una IllegalStateException . This in particular mean that initialData(Realm.Transaction) will not work in combination with a read only Realm and setting this will result in a IllegalStateException being thrown. Marking a Realm as read only only applies to the Realm in this process. Other processes can still write to the Realm. |
rxFactory
Establece la RxObservableFactory que se usa para crear Rx Observables a partir de objetos Realm. La fábrica por defecto es RealmObservableFactory . Parámetros
|
schemaVersion
Establece la versión del esquema del Realm. Esto debe ser igual o superior a la versión del esquema del archivo Realm existente, en caso de que haya alguno. Si la versión del esquema es más alta que la ya existente en Realm, se necesita una migración. Realm lanzará una io.realm.exceptions.RealmMigrationNeededException si no se proporciona ningún código de migración. |