Skip to content
This repository has been archived by the owner on Mar 9, 2022. It is now read-only.

My First TouchDB Replication

mschoch edited this page Jul 17, 2012 · 13 revisions

This guide will help you get started with TouchDB-Android and perform your first replication.

  1. Add the TouchDB Projects to your Eclipse workspace (as described here https://github.com/couchbaselabs/TouchDB-Android/wiki/Building-TouchDB-Android
  2. Create a new Android Project (targeting Android SDK 2.2 or newer)
  3. Add the Android Library references to TouchDB-Android and TouchDB-Android
  4. Add the following code to the onCreate() method of the Application's main activity:
      // start TouchDB-Ektorp adapter
      HttpClient httpClient = new TouchDBHttpClient(tdserver);
      CouchDbInstance server = new StdCouchDbInstance(httpClient);

      // create a local database
      CouchDbConnector db = server.createConnector("testdb", true);

      // push this database to the test replication server
      ReplicationCommand pushCommand = new ReplicationCommand.Builder()
          .source("https://example.iriscouch.com/example_db")
          .target("testdb")
          .continuous(true)
          .build();

      ReplicationStatus status = server.replicate(pushCommand);