Skip to content

Quickstart in Couchbase Lite using a standalone database with Android and Java. This tutorial will show you how to use Sync Gateway to sync information between your local database and Couchbase Server.

License

Notifications You must be signed in to change notification settings

couchbase-examples/android-java-cblite-userprofile-sync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Standalone

Quickstart in Couchbase Lite Data Sync with Android and Java

Build an Android App in Java with Couchbase Lite

Couchbase Sync Gateway is a key component of the Couchbase Mobile stack. It is an internet-facing synchronization mechanism that securely syncs data across devices as well as between devices and the cloud. Couchbase Mobile is built upon a websocket based replication protocol.

The core functions of the Sync Gateway includes:

  • Data Synchronization across devices and the cloud
  • Authorization
  • Access Control
  • Data Validation

This repo is designed to show you an app that allows users to log in and make changes to their user profile information. User profile information is persisted as a Document in the local Couchbase Lite Database. When the user logs out and logs back in again, the profile information is loaded from the Database.

Full documentation can be found on the Couchbase Developer Portal.

Prerequisites

To run this prebuilt project, you will need:

Installing Couchbase Lite Framework

  • This project already contains the appropriate additions for downloading and utilizing the Android Couchbase Lite dependency module. However, in the future, to include Couchbase Lite support within an Android app add the following within the gradle settings file (src/gradle.settings)
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        maven { url "https://mobile.maven.couchbase.com/maven2/dev/" } // << add this repository
        google()
        mavenCentral()
    }
}
  • next, be sure you are using the most recent release of Couchbase Lite Mobile for Android. In the module build file (src/app/build.gradle) check this line to verify that the version number is correct:
dependencies {
    ...

    implementation 'com.couchbase.lite:couchbase-lite-android-ee:3.1.2'
}

App Architecture

The sample app follows the MVP pattern, separating the internal data model, from a passive view through a presenter that handles the logic of our application and acts as the conduit between the model and the view

Try it out

  • Open src/build.gradle using Android Studio.
  • Build and run the project.
  • Verify that you see the login screen.

Conclusion

This code is an example of how to use a Sync Gateway to synchronize data between Couchbase Lite enabled clients. The Couchbase Developer Portal tutorial will discuss how to configure your Sync Gateway to enforce relevant access control, authorization and data routing between Couchbase Lite enabled clients.

About

Quickstart in Couchbase Lite using a standalone database with Android and Java. This tutorial will show you how to use Sync Gateway to sync information between your local database and Couchbase Server.

Topics

Resources

License

Stars

Watchers

Forks