androidcouchbasecouchbase-litecouchbase-sync-gateway

Sync Data between Android App and Server Couchbase Lite


I want Couchbase to first temporary store the data, and then automatically sync it with Server. How do I achieve this ?

For example, In note-making app, I add a note and Couchbase should automatically add it to the Server.


Solution

  • You're in luck! The requirement you've described is exactly how Couchbase Mobile works.

    Couchbase Mobile is comprised of two parts:

    1. Couchbase Lite: A stand-alone embedded database that you can use directly within your mobile app.
    2. Sync Gateway: a synchronization mechanism that securely syncs data between mobile clients and server.

    So, back to your question. In order to achieve what you're looking for you would first create an instance of your Couchbase Lite database. From there, as you would expect, you can perform basic CRUD operations, query data, etc. You can find more information on the built-in capabilities here:

    1. iOS (Swift)
    2. iOS (Obj-C)
    3. Android (Java)
    4. Xamarin (C#)

    Once you've created an embedded database you can start replication (synchronization) on it by using the Sync Gateway integration that comes with the Couchbase.Lite and Couchbase.Lite.Enterprise SDK component for iOS, Android, or Xamarin.

    I recommend checking out the following tutorials for using Couchbase Lite and Sync Gateway: