Skip to content

Getting Started

MikeFair edited this page Oct 25, 2012 · 24 revisions

Demo Application

The best place to get started is by looking at the TouchDB version of the GrocerySync application

Keep in mind to use the --branch=touchdb flag on the git clone command or else you'll end up with the master branch that has the couchbase-mobile codebase in it.

Using TouchDB in your own application

As we do not have precompiled binary packages yet, the following assume that you have the TouchDB-Android projects imported into your workspace.

  1. Create a new Android application using SDK 2.2 or newer (or select an existing project meeting this requirement)
  2. Select the Android tab within your project's properties.
  3. In the Library section, press Add, select TouchDB-Android from the list and press OK.
  4. Press Add again, select TouchDB-Android-Ektorp from the list and press OK.
  5. Press OK again closing the project's properties.
  6. Open your projects main Activity
  7. Add the following static initilization block:
  1. Add the following to start an instance of TDServer:
    TDServer server = null;
    String filesDir = getFilesDir().getAbsolutePath();
    try {
        server = new TDServer(filesDir);
    } catch (IOException e) {
        Log.e(TAG, "Error starting TDServer", e);
  1. Add the following code to connect Ektorp to this TDServer instance:
        HttpClient httpClient = new TouchDBHttpClient(server);
        CouchDbInstance dbInstance = new StdCouchDbInstance(httpClient);
  1. You can now interact with this CouchDbInstance just as you would any other CouchDB, the only difference being this one is backed by TouchDB on your device (and not using any sockets). For the full capabilities of Ektorp see
Something went wrong with that request. Please try again.