Class SyncConfiguration
On this page
- io.realm.mongodb.sync
- Nested Class Summary
- Method Summary
- Inherited Methods
- Method Detail
- defaultConfig
- equals
- forRecovery
- getClientResetHandler
- getErrorHandler
- getInitialDataTransaction
- getInitialRemoteDataTimeout
- getInitialSubscriptionsHandler
- getPartitionValue
- getServerUrl
- getSessionStopPolicy
- getSyncClientResetStrategy
- getUrlPrefix
- getUser
- hashCode
- isFlexibleSyncConfiguration
- isPartitionBasedSyncConfiguration
- isSyncConfiguration
- realmExists
- shouldDeleteRealmOnLogout
- shouldWaitForInitialRemoteData
- toString
io.realm.mongodb.sync
A SyncConfiguration is used to setup a realm that can be synchronized between devices using MongoDB Realm.
A valid User is required to create a SyncConfiguration . See Credentials and App.loginAsync(Credentials, App.Callback) for more information on how to get a user object.
A minimal SyncConfiguration can be found below.
App app = new App("app-id"); User user = app.login(Credentials.anonymous()); SyncConfiguration config = SyncConfiguration.defaultConfiguration(user, "partition-value"); Realm realm = Realm.getInstance(config);
Synchronized Realms only support additive migrations which can be detected and performed automatically, so the following builder options are not accessible compared to a normal Realm:
deleteRealmIfMigrationNeeded()
migration(Migration)
Synchronized Realms are created by using Realm.getInstance(RealmConfiguration) and Realm.getDefaultInstance() like ordinary unsynchronized Realms.
Nested Class Summary
Modifier and Type | Class and Description |
---|---|
public static interface | |
public static final |
Method Summary
Modifier and Type | Method and Description |
---|---|
public static SyncConfiguration | Returns a default Partition-based Sync configuration for the given user and partition value. |
public static SyncConfiguration | Returns a default Partition-based Sync configuration for the given user and partition value. |
public static SyncConfiguration | Returns a default Partition-based Sync configuration for the given user and partition value. |
public static SyncConfiguration | Returns a default Partition-based Sync configuration for the given user and partition value. |
public static SyncConfiguration | Returns a default Flexible Sync configuration for the given user. |
public boolean | |
public static RealmConfiguration | Returns a RealmConfiguration appropriate to open a read-only, non-synced Realm to recover any pending changes. |
public static RealmConfiguration | Returns a RealmConfiguration appropriate to open a read-only, non-synced Realm to recover any pending changes. |
Returns the Client Reset handler for this SyncConfiguration. | |
public SyncSession.ErrorHandler | Returns the error handler for this SyncConfiguration. |
protected Realm.Transaction | Returns the transaction instance with initial data. |
public long | Returns the timeout defined when downloading any initial data the first time the Realm is opened. |
Returns the configured initial subscription handler for this realm. | |
public BsonValue | Returns the value this Realm is partitioned on. |
public URI | getServerUrl () Returns the server URI for the remote MongoDB Realm the local Realm is synchronizing with. |
public OsRealmConfig.SyncSessionStopPolicy | NOTE: Only for internal usage. |
public SyncClientResetStrategy | Returns the sync client reset strategy for this SyncConfiguration. |
public String | getUrlPrefix () Returns the url prefix used when establishing a sync connection to the Realm Object Server. |
public User | getUser () Returns the user. |
public int | hashCode () |
public boolean | Returns whether or not this configuration is for opening a Realm configured for Flexible Sync. |
public boolean | Returns whether or not this configuration is for opening a Realm configured for Partition-based Sync. |
protected boolean | |
protected boolean | realmExists () Checks if the Realm file defined by this configuration already exists. |
public boolean | Returns |
public boolean | Returns |
public String | toString () |
Inherited Methods
Methods inherited from class java.lang.Object :
getClass
,hashCode
,equals
,clone
,toString
,notify
,notifyAll
,wait
,wait
,wait
,finalize
Methods inherited from class io.realm.RealmConfiguration :
getRealmDirectory
,getRealmFileName
,getEncryptionKey
,getSchemaVersion
,getMigration
,shouldDeleteRealmIfMigrationNeeded
,getDurability
,getSchemaMediator
,getInitialDataTransaction
,hasAssetFile
,getAssetFilePath
,getCompactOnLaunchCallback
,getRealmObjectClasses
,getPath
,realmExists
,getRxFactory
,getFlowFactory
,isReadOnly
,isRecoveryConfiguration
,getMaxNumberOfActiveVersions
,isAllowWritesOnUiThread
,isAllowQueriesOnUiThread
,equals
,getInstance
,hashCode
,createSchemaMediator
,toString
,isSyncConfiguration
,forRecovery
Method Detail
defaultConfig
Returns a default Partition-based Sync configuration for the given user and partition value. Parameters
Returns the default configuration for the given user and partition value. |
Returns a default Partition-based Sync configuration for the given user and partition value. Parameters
Returns the default configuration for the given user and partition value. |
Returns a default Partition-based Sync configuration for the given user and partition value. Parameters
Returns the default configuration for the given user and partition value. |
Returns a default Partition-based Sync configuration for the given user and partition value. Parameters
Returns the default configuration for the given user and partition value. |
Returns a default Flexible Sync configuration for the given user. Parameters
Returns the default Flexible Sync configuration for the given user. TipSee also:
|
equals
Overrides
|
forRecovery
Returns a RealmConfiguration appropriate to open a read-only, non-synced Realm to recover any pending changes. This is useful when trying to open a backup/recovery Realm (after a client reset). Note: This will use the default Realm module (composed of all RealmModel ), and assume no encryption should be used as well. Parameters
Returns RealmConfiguration that can be used offline |
public static RealmConfiguration forRecovery ( ) |
---|
Returns a RealmConfiguration appropriate to open a read-only, non-synced Realm to recover any pending changes. This is useful when trying to open a backup/recovery Realm (after a client reset). Parameters
Returns RealmConfiguration that can be used offline |
getClientResetHandler
Returns the Client Reset handler for this SyncConfiguration. Returns the Client Reset handler. |
getErrorHandler
public SyncSession.ErrorHandler getErrorHandler () |
---|
Returns the error handler for this SyncConfiguration. Returns the error handler. |
getInitialDataTransaction
protected Realm.Transaction getInitialDataTransaction () |
---|
Returns the transaction instance with initial data. Returns the initial data transaction. Overrides
|
getInitialRemoteDataTimeout
Returns the timeout defined when downloading any initial data the first time the Realm is opened.This value is only applicable if shouldWaitForInitialRemoteData() returns Returns the time Realm will wait for all changes to be downloaded before it is aborted and an exception is thrown. |
getInitialSubscriptionsHandler
Returns the configured initial subscription handler for this realm. Returns the handler used to configure initial subscriptions for this realm. |
getPartitionValue
public BsonValue getPartitionValue () |
---|
Returns the value this Realm is partitioned on. The partition key is a property defined in MongoDB Realm. All classes with a property with this value will be synchronized to the Realm. Returns the value being used by MongoDB Realm to partition the server side MongoDB Database into Realms that can be synchronized independently. Throws
|
getServerUrl
public URI getServerUrl () |
---|
Returns the server URI for the remote MongoDB Realm the local Realm is synchronizing with. Returns URI identifying the MongoDB Realm this local Realm is synchronized with. |
getSessionStopPolicy
public OsRealmConfig.SyncSessionStopPolicy getSessionStopPolicy () |
---|
NOTE: Only for internal usage. May change without warning. Returns the stop policy for the session for this Realm once the Realm has been closed. Returns the stop policy used by the session once the Realm is closed. |
getSyncClientResetStrategy
Returns the sync client reset strategy for this SyncConfiguration. Returns the sync client reset strategy. |
getUrlPrefix
public String getUrlPrefix () |
---|
Returns the url prefix used when establishing a sync connection to the Realm Object Server. |
getUser
hashCode
public int hashCode () |
---|
Overrides
|
isFlexibleSyncConfiguration
public boolean isFlexibleSyncConfiguration () |
---|
Returns whether or not this configuration is for opening a Realm configured for Flexible Sync. Returns
|
isPartitionBasedSyncConfiguration
public boolean isPartitionBasedSyncConfiguration () |
---|
Returns whether or not this configuration is for opening a Realm configured for Partition-based Sync. Returns
|
isSyncConfiguration
protected boolean isSyncConfiguration () |
---|
Overrides
|
realmExists
protected boolean realmExists () |
---|
Checks if the Realm file defined by this configuration already exists.WARNING: This method is just a point-in-time check. Unless protected by external synchronization another thread or process might have created or deleted the Realm file right after this method has returned. Returns
Overrides
|
shouldDeleteRealmOnLogout
public boolean shouldDeleteRealmOnLogout () |
---|
shouldWaitForInitialRemoteData
public boolean shouldWaitForInitialRemoteData () |
---|
Returns Returns
|
toString
Overrides
|