Join us at MongoDB.local London on 7 May to unlock new possibilities for your data. Use WEB50 to save 50%.
Register now >
Docs Menu
Docs Home
/ /
io.realm.mongodb.sync

Class Sync

java.lang.Object
io.realm.mongodb.sync.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();

Tip

Modificador y Tipo
Clase y descripción

public static

Modificador y Tipo
Método y descripción

Obtiene una colección de todas las SyncSession almacenadas en caché.

public synchronized SyncSession

Gets any cached SyncSession for the given SyncConfiguration or create a new one if no one exists.

public synchronized SyncSession

SyncConfiguration syncConfiguration
)

Obtiene una SyncSession en caché para la SyncConfiguration dada o lanza una excepción si aún no existe ninguna.

public void

Realm will automatically detect when a device gets connectivity after being offline and resume syncing.

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

public synchronized Collection getAllSessions ()

Obtiene una colección de todas las SyncSession almacenadas en caché.

Devuelve

una colección de SyncSession.

public synchronized SyncSession getOrCreateSession (
SyncConfiguration syncConfiguration
)

Obtenga cualquier SyncSession almacenada en caché para la SyncConfiguration dada o cree una nueva si no existe ninguna. Nota: Esto es principalmente para uso interno, en su lugar, considera usar getSession(SyncConfiguration).

Parámetros

  • syncConfiguration - configuration object for the synchronized Realm.

Devuelve

el SyncSession para el Realm especificado.

Throws

public synchronized SyncSession getSession (
SyncConfiguration syncConfiguration
)

Obtén una SyncSession en caché para la SyncConfiguration dada o lanza una excepción si aún no existe. Debería existir una sesión después de abrir un Realm con una SyncConfiguration .

Parámetros

  • syncConfiguration - configuration object for the synchronized Realm.

Devuelve

el SyncSession para el Realm especificado.

Throws

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.

En esos casos, puede ser beneficioso llamar a este método manualmente, lo que obligará a todas las sesiones a intentar reconectarse inmediatamente y restablecer cualquier temporizador que estén usando para el retroceso incremental.

Volver

SubscriptionSet.UpdateCallback

En esta página