Cloudrail - Android


Advertisements

This section gives an introduction on how to use CloudRail's Android SDK.

Setup

The easiest way to install is via Maven. If you are using Android Studio with Gradle, it suffices to add the following to your build.gradle file

dependencies {
   compile 'com.cloudrail:cloudrail-si-android:2.8.1
}

Usage

The following example shows how to create a new folder and upload a file from an Android application's assets to the newly created folder on any cloud storage provider.

java
CloudRail.setAppKey("[CloudRail License Key]");

// CloudStorage cs = new Box(context, "[clientIdentifier]", "[clientSecret]");
// CloudStorage cs = new OneDrive(context, "[clientIdentifier]", "[clientSecret]");
// CloudStorage cs = new GoogleDrive(context, "[clientIdentifier]", "[clientSecret]");
CloudStorage cs = new Dropbox(context, "[clientIdentifier]", "[clientSecret]");

new Thread() {
   @Override
   public void run() {
      cs.createFolder("/TestFolder"); // <---
      InputStream stream = null;
      
      try {
         AssetManager assetManager = getAssets();
         stream = assetManager.open("UserData.csv");
         long size = assetManager.openFd("UserData.csv").getLength();
         cs.upload("/TestFolder/Data.csv", stream, size, false); // <---
      } catch (Exception e) {
         // TODO: handle error
      } finally {
         // TODO: close stream
      }
   }
}.start();
Advertisements