Skip to end of metadata
Go to start of metadata
You are viewing an old version of this page. View the current version. Compare with Current  |   View Page History

Download

Get the 2.0.0-beta release here.

Getting Started

We're just gonna jump right in here and talk how-to. These instructions require you to have installed Eclipse and the Android SDK, via these instructions or similar. Once you have that, you can do this:

  1. Create a new Android project or select an existing project
  2. Copy the Couchbase.zip and couchbase.xml files into the top-level of the project:
  3. Right-click on couchbase.xml and select Run As > Ant Build (or select it and click the green Run arrow).
  4. Refresh your project

Your App Code

Now that your project supports Couchbase, starting Cocuhbase is accomplished by adding a few things to your application's Main Activity.

1. Create an instance of ICouchbaseDelegate, you can implement these methods to respond to Couchbase events:
 
  private final ICouchbaseDelegate couchCallbackHandler = newICouchbaseDelegate() {

      @Override
      public void couchbaseStarted(String host, int port) color   
      @Override
     
public void exit(String error) color

   }


 

2. Declare a ServiceConnection instance to keep a reference to the Couchbase service:
 
    private ServiceConnection couchServiceConnection;
 
3.  Add a method to start Couchbase:
 
    public void startCouchbase() {
        CouchbaseMobile couch = newCouchbaseMobile(getBaseContext(), couchCallbackHandler);
        couchServiceConnection = couch.startCouchbase();
    } 
 
4.  Call the startCouchbase method from the appropriate Activity lifecycle methods.  For many applications the onCreate method is appropriate:
 
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ...
        startCouchbase();
    }

Once Couchbase has started you will get a notification by your delegate callback being called with couchbaseStarted. At that point you have can construct a server and database URLs, and proceed by using high-level libraries like Ektorp.
 

Client Library

Example Applications

Documentation

Join the Community

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.