public class SyncConfiguration extends RealmConfiguration
SyncConfiguration
is used to setup a Realm that can be synchronized between devices using the Realm
Object Server.
A valid SyncUser
is required to create a SyncConfiguration
. See SyncCredentials
and
SyncUser.loginAsync(SyncCredentials, String, SyncUser.Callback)
for more information on
how to get a user object.
A minimal SyncConfiguration
can be found below.
SyncConfiguration config = new SyncConfiguration.Builder(context)
.serverUrl("realm://objectserver.realm.io/~/default")
.user(myUser)
.build();
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)
Realm.getInstance(RealmConfiguration)
and
Realm.getDefaultInstance()
like ordinary unsynchronized Realms.Modifier and Type | Class and Description |
---|---|
static class |
SyncConfiguration.Builder
Builder used to construct instances of a SyncConfiguration in a fluent manner.
|
DEFAULT_REALM_NAME, KEY_LENGTH
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
static RealmConfiguration |
forRecovery(String canonicalPath)
Returns a
RealmConfiguration appropriate to open a read-only, non-synced Realm to recover any pending changes. |
static RealmConfiguration |
forRecovery(String canonicalPath,
byte[] encryptionKey,
Object... modules)
Returns a
RealmConfiguration appropriate to open a read-only, non-synced Realm to recover any pending changes. |
SyncSession.ErrorHandler |
getErrorHandler() |
String |
getServerCertificateAssetName()
Returns the name of certificate stored under the
assets , to be used to validate
the TLS connection to the Realm Object Server. |
String |
getServerCertificateFilePath()
Returns the name of the certificate copied from
assets into internal storage, so it
can be used to validate the TLS connection to the Realm Object Server. |
URI |
getServerUrl()
Returns the fully disambiguated URI for the remote Realm i.e., the
/~/ placeholder has been replaced
by the proper user ID. |
OsRealmConfig.SyncSessionStopPolicy |
getSessionStopPolicy()
NOTE: Only for internal usage.
|
SyncUser |
getUser()
Returns the user.
|
int |
hashCode() |
boolean |
isPartialRealm()
Whether this configuration is for a Query-based synchronization Realm.
|
boolean |
shouldDeleteRealmOnLogout()
Returns
true if the Realm file must be deleted once the SyncUser owning it logs out. |
boolean |
shouldWaitForInitialRemoteData()
Returns
true if the Realm will download all known changes from the remote server before being opened the
first time. |
boolean |
syncClientValidateSsl()
Whether the Realm Object Server certificate should be validated in order
to establish a valid TLS connection.
|
String |
toString() |
getCompactOnLaunchCallback, getDurability, getEncryptionKey, getMigration, getPath, getRealmDirectory, getRealmFileName, getRealmObjectClasses, getRxFactory, getSchemaVersion, isReadOnly, isRecoveryConfiguration, shouldDeleteRealmIfMigrationNeeded
public static RealmConfiguration forRecovery(String canonicalPath, byte[] encryptionKey, Object... modules)
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).canonicalPath
- the absolute path to the Realm file defined by this configuration.encryptionKey
- the key used to encrypt/decrypt the Realm file.modules
- if specified it will restricts Realm schema to the provided module.public static RealmConfiguration forRecovery(String canonicalPath)
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.canonicalPath
- the absolute path to the Realm file defined by this configuration.public boolean equals(Object o)
equals
in class RealmConfiguration
public int hashCode()
hashCode
in class RealmConfiguration
public String toString()
toString
in class RealmConfiguration
public SyncUser getUser()
public URI getServerUrl()
/~/
placeholder has been replaced
by the proper user ID.URI
identifying the remote Realm this local Realm is synchronized with.public SyncSession.ErrorHandler getErrorHandler()
public boolean shouldDeleteRealmOnLogout()
true
if the Realm file must be deleted once the SyncUser
owning it logs out.true
if the Realm file must be deleted if the SyncUser
logs out. false
if the file
is allowed to remain behind.public String getServerCertificateAssetName()
assets
, to be used to validate
the TLS connection to the Realm Object Server.assets
.getServerCertificateFilePath()
public String getServerCertificateFilePath()
assets
into internal storage, so it
can be used to validate the TLS connection to the Realm Object Server.getServerCertificateAssetName()
public boolean syncClientValidateSsl()
true
to validate the remote certificate, or false
to bypass certificate validation.public boolean shouldWaitForInitialRemoteData()
true
if the Realm will download all known changes from the remote server before being opened the
first time.true
if all remote changes will be downloaded before the Realm can be opened. false
if
the Realm can be opened immediately.public OsRealmConfig.SyncSessionStopPolicy getSessionStopPolicy()
public boolean isPartialRealm()
SyncConfiguration.Builder.partialRealm()
, opening the Realm, and then calling
Realm.subscribeToObjects(Class, String, Realm.PartialSyncCallback)
with the type of
object you're interested in, a string containing a query determining which objects you want
to subscribe to, and a callback which will report the results.true
to open a Query-based synchronization Realm false
otherwise.