Class Sync
On this page
io.realm.mongodb.sync
A sync manager handling synchronization of local Realms with remote Realm Apps.The primary role of this is to access the SyncSession for a synchronized Realm. After opening the synchronized Realm you can access the SyncSession and perform synchronization related operations as shown below:
App app = new App("app-id"); User user = app.login(Credentials.anonymous()); SyncConfiguration syncConfiguration = new SyncConfiguration.Builder(user, "<partition value>") .build(); Realm instance = Realm.getInstance(syncConfiguration); SyncSession session = app.getSync().getSession(syncConfiguration); instance.executeTransaction(realm -> { realm.insert(...); }); session.uploadAllLocalChanges(); instance.close();
Nested Class Summary
Modifier and Type | Class and Description |
---|---|
public static |
Method Summary
Modifier and Type | Method and Description |
---|---|
public synchronized Collection | Gets a collection of all the cached SyncSession . |
public synchronized SyncSession | Gets any cached SyncSession for the given SyncConfiguration or create a new one if no one exists. |
public synchronized SyncSession | Gets a cached SyncSession for the given SyncConfiguration or throw if no one exists yet. |
public void | reconnect () Realm will automatically detect when a device gets connectivity after being offline and resume syncing. |
Inherited Methods
Methods inherited from class java.lang.Object :
getClass
,hashCode
,equals
,clone
,toString
,notify
,notifyAll
,wait
,wait
,wait
,finalize
Method Detail
getAllSessions
public synchronized Collection getAllSessions () |
---|
getOrCreateSession
Gets any cached SyncSession for the given SyncConfiguration or create a new one if no one exists. Note: This is mainly for internal usage, consider using getSession(SyncConfiguration) instead. Parameters
Returns the SyncSession for the specified Realm. Throws
|
getSession
Gets a cached SyncSession for the given SyncConfiguration or throw if no one exists yet. A session should exist after you open a Realm with a SyncConfiguration . Parameters
Returns the SyncSession for the specified Realm. Throws
|
reconnect
public void reconnect () |
---|
Realm will automatically detect when a device gets connectivity after being offline and resume syncing.However, as some of these checks are performed using incremental backoff, this will in some cases not happen immediately. In those cases it can be beneficial to call this method manually, which will force all sessions to attempt to reconnect immediately and reset any timers they are using for incremental backoff. |