Dropbox offers native SDKs for iOS, OS X and Android. This page includes instructions on how to download and set up SDKs for each platform, as well as links to SDKs provided by the community for other environments.
Before building an app using the Sync API, you'll need to create an app with the App folder or File type permission in the App Console (Full Dropbox permission is not supported with the Sync API). Visit the developer guide for more information on the different types of permissions.
These instructions assume you're using Eclipse with the ADT plug-in, but you can also use the Sync API without Eclipse. The Sync API requires Android API 4 or later.
Download the Sync API Android SDK linked above. The necessary libraries are located in the libs directory of the SDK package. The .jar file in the libs directory contains the Java classes which make up the Android SDK. The subdirectories contain the native components, built for each supported Android platform. You can safely omit some of them if you know which platforms your app needs to support ("armeabi" is the most common).
The recommended way to create your first Datastore API app is to use Eclipse, and the tutorial assumes that you are. If you don't have Eclipse installed, download the Android Development Tools Bundle which includes Eclipse and the ADT plug-in.
To add the Sync API to your Eclipse project:
To allow Eclipse to display Javadoc documentation for SDK classes, you can create a dropbox-sync-sdk-android.jar.properties file in your project's libs directory containing a path to the javadoc directory of the Android SDK package as follows.
# Replace the path below with the correct path on your system doc=../../../dropbox-sync-sdk-android/javadoc
The Sync API needs permission to access the Internet. Additionally, a few SDK components need to be published so that Android can find them. Here are the two snippets to add to your AndroidManifest.xml.
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<activity android:name="com.dropbox.sync.android.DbxAuthActivity" /> <activity android:name="com.dropbox.client2.android.AuthActivity" android:launchMode="singleTask" > <intent-filter> <data android:scheme="db-APP_KEY" /> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <service android:name="com.dropbox.sync.android.DbxSyncService" android:enabled="true" android:exported="false" android:label="Dropbox Sync" />
If you want to see the Sync API in action, check out the examples directory in the SDK bundle. There you can find a simple "Hello Dropbox" example that demonstrates the code in this tutorial, as well as a note-taking app that uses the Sync API to save notes to Dropbox and alerts you if the notes are updated. This app will also sync notes with the notes example included in the SDKs for other platforms. Here's how to build and run a sample app.