This repository was archived by the owner on Mar 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 59
Getting Started
mschoch edited this page May 15, 2012
·
24 revisions
The best place to get started is by looking at the TouchDB version of the GrocerySync application
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:
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).