/Android-Couchbase

The android build for humans.

Primary LanguageJava

New Android-Couchbase Instructions

NOTE: Do not use the source in this repository, only the binary Downloads and instructions

Prerequisites

  • Android SDK
  • Eclipse ADT

Instructions

  1. Create a new Android project or select an existing project

  2. Download Couchbase.zip and couchbase.xml into the top-level of the project:

  1. Right-click on couchbase.xml and select Run As > Ant Build

  2. Refresh your project

Starting Couchbase

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 mCallback = new ICouchbaseDelegate.Stub() {
        @Override
        public void couchbaseStarted(String host, int port) {}
    
        @Override
        public void installing(int completed, int total) {}
    
        @Override
        public void exit(String error) {}
    };
  1. Declare a ServiceConnection instance to keep a reference to the Couchbase service
    private ServiceConnection couchServiceConnection;
  1. Add a method to start Couchbase
	public void startCouchbase() {
		CouchbaseMobile couch = new CouchbaseMobile(getBaseContext(), mCallback);
		couchServiceConnection = couch.startCouchbase();
	}
  1. 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();
    }

Help and More Information

For help or more information please join the Couchbase Mobile Google Group:

https://groups.google.com/group/mobile-couchbase