Class Sync


  • public abstract class Sync
    extends Object
    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();
     
    See Also:
    App.getSync(), getSession(SyncConfiguration)
    • Method Detail

      • 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.