This repository has been archived by the owner on Mar 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 60
Getting Started
MikeFair edited this page Oct 25, 2012
·
24 revisions
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.
As we do not have precompiled binary packages yet, the following assume that you have the TouchDB-Android projects imported into your workspace.
- Create a new Android application using SDK 2.2 or newer (or select an existing project meeting this requirement)
- Select the Android tab within your project's properties.
- In the Library section, press Add, select TouchDB-Android from the list and press OK.
- Press Add again, select TouchDB-Android-Ektorp from the list and press OK.
- Press OK again closing the project's properties.
- Open your projects main Activity
- Add the following static initilization block:
{
TDURLStreamHandlerFactory.registerSelfIgnoreError();
}
- 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);
}
- Add the following code to connect Ektorp to this TDServer instance:
HttpClient httpClient = new TouchDBHttpClient(server);
CouchDbInstance dbInstance = new StdCouchDbInstance(httpClient);
- 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 http://ektorp.org/