Android and AWS Mobile SDK

Omolara Adejuwon
Larikraun’s Blog
Published in
1 min readJun 3, 2016

Amazon Web Service (AWS) is an household name. So, this blog post is not about how much sense AWS makes. This is all about how you can use AWS Mobile SDK in your Android application. I feel it’s more convenient for me compared to using the REST APIs.

For this tutorial, I am going to demonstrate how to store and retrieve images from your Amazon s3 bucket using the SDK. This tutorial assumes you have an AWS account.

The first thing to do is to include the needed SDKs in your project. To achieve this, we add the following dependencies.

dependencies {
compile 'com.amazonaws:aws-android-sdk-core:2.+'
compile 'com.amazonaws:aws-android-sdk-s3:2.+'
}

It is not encouraged to embed credentials in the application, we need to get an IDENTITY POOL ID using the Amazon Cognito Identity service. You can get that done by following the steps described in the documentation.

After this is done, we can gallantly continue to the Android implementation.

First, we update our manifest file to request for some permissions.

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

You can insert the following snippet where you need to trigger the event that handles the connection to AmazonClient, creation and retrieval of buckets and objects.

Be sure not to run the code on the main UI thread.

If you have done everything right, you should be happy with the results right now. Feel free to leave a comment if there is a need to.

--

--

Omolara Adejuwon
Larikraun’s Blog

Code and everything in between. Android Engineer. Editor @proandroiddev