Data Sync Locally on Device
Couchbase Lite supports replication between two local databases. This allows a Couchbase Lite replicator to store data on secondary storage. It is especially useful in scenarios where a user’s device may be damaged and its data moved to a different device.
val repl = Replicator( ReplicatorConfigurationFactory.create( database = database1, target = DatabaseEndpoint(database2), type = ReplicatorType.PULL ) ) // Create replicator (be sure to hold a reference somewhere that will prevent the Replicator from being GCed) repl.start() replicator = repl
DatabaseEndpoint targetDatabase = new DatabaseEndpoint(database2); ReplicatorConfiguration replicatorConfig = new ReplicatorConfiguration(database1, targetDatabase); replicatorConfig.setReplicatorType(ReplicatorConfiguration.ReplicatorType.PUSH); // Create replicator (be sure to hold a reference somewhere that will prevent the Replicator from being GCed) replicator = new Replicator(replicatorConfig); replicator.start();