Android Dropbox API – Upgrade from Version 1 to Version 2

 In CloudRail

You might have seen this email appear in your Inbox about the official Android Dropbox API.

You might have come here because you are looking for an easier way to swap over from using Version 1 to Version 2 of the Android Dropbox SDK. Thing is, you need to consider how often this can happen. How likely is it that Dropbox will have another update round in the future? Or what about any of the other services you use? This is why now is the perfect time to add CloudRail.

With CloudRail, not only do you get an easy to upgrade from Version 1 to Version 2 of the Android Dropbox API, but you also get access to other Cloud Storage services, and in fact, many different Cloud APIs.

CloudRail Single Interface abstracts the APIs for Cloud Services, including Dropbox, and gives developers a set of functions that are universal across each service. This means that, for example, the function upload() works exactly the same for Dropbox as it does for Google Drive.

And in fact, after you follow this Dropbox API Android Tutorial, you will also be equipped with the skills to add any of the other services below to your app.

Android Dropbox Tutorial – Replacing the Android Dropbox API V1 with CloudRail

Firstly you are going to want to grab the CloudRail SDK. This one package includes all the services we offer, not just the Android Dropbox SDK.

To add the CloudRail Library Manually

  • Download the SDK here.
  • Unzip the file.
  • Create a new Android project or switch to an existing one.
  • Copy the library file (*.aar file) into your project’s lib folder.
  • Add the file as a Module to your project.

To add the CloudRail Library via Git

  • Create a new Android project or switch to an existing one.
  • Clone the GitHub project into a folder in your project.
  • Add the *.aar file in that folder to your project.
  • (optional) Add a git pull on that repository to your build process to always have the latest version.

To add the CloudRail Library with Maven

Just add the following to your build.gradle:

Set up code for this Dropbox Android Tutorial

Your first step when adding CloudRail functionality to your application is to start off by instantiating the CloudRail object

As you can see above, the code example also includes how you may use the CloudRail API to connect up to other external services. Of course, the uncommented part is how we are going to use CloudRail as a sort of Android Dropbox SDK.

From here, we may now access all of the functions of the dropbox implementation simply by calling the “dropbox” object.

You will, of course, need to replace ‘<clientID>’ and ‘<clientSecret>’ above with those values you have already gotten from Dropbox. If you are using any of the other services, you will also want to sign up for them and get the credentials.

Android Dropbox Tutorial – Upload your First File

Of course, you probably want to get diving into using the Android Dropbox API as implemented by CloudRail. Let’s take a look at what is likely the most common task with Dropbox; uploading a file:

As you can see here, the code is pretty self-explanatory.

  • Line 1: We set a string to identify the path of which we want to upload the file to in the user’s Dropbox.
  • Line 2: We get a reference to the content (in most cases, a file stored locally) we want to upload to Dropbox. This content is represented through an InputStream.
  • Line 3: We create a Long variable with the size of the file of which we are uploading, to ensure that the file is correctly uploaded.
  • Line 4: We set if we want to overwrite the file, if it already exists in the User’s dropbox.
  • Line 6: And lastly, we call the upload() method of the Dropbox object.

The other functions of the CloudRail implementation of Cloud Storage services is out of the scope of this dropbox tutorial. Android developers, however, can check out the documentation at docs.cloudrail.com.

Other reasons to use CloudRail for your Android Dropbox API.

Not only is upgrading from Version 1 of the Dropbox API is the perfect time to start integrating CloudRail into your application, it is the perfect time to explore all of the other great features of the CloudRail Library. These are:

  • No Middleware: Unlike other similar solutions, CloudRail doesn’t put a server in the way of your app and your application. This means that you aren’t reliant on a third party to be up and running for your application, and also means that you don’t have to entrust us with the privacy of your data.
  • Many Different Services: We bundle up all services into what we call interfaces. Currently implemented interfaces are Cloud Storage, Social Media Profiles, Payment Services, SMS, Email and Points of Information.
  • Regular Updates: CloudRail is updated at least once a week. Additionally, when API providers, such as Dropbox, change the implementation of their API you can be assured that Dropbox will update and that upgrading to the newest version will be as easy as updating the CloudRail Library in your application.
  • Simple Programing: As we abstract all the methods for each service, there is no confusion between different services implementing different ways to do things. To us, for example, upload() is a standard function that should take the same inputs and outputs for each service.
  • Completely Free: CloudRail is completely free for use, for commercial and non-commercial projects. We do not charge for usage quotas, for number of integrations, or anything else.

So, what are you waiting for? Use the need to upgrade your Android Dropbox API from Version 1 to Version 2 to upgrade to using CloudRail and make your coding life easier.

Recent Posts