This article demonstrates how to use VutaImage (A lightweight Android libray I created to make it easy to download images from a url with a simple API) to download images from a url and save it in your device.
NB: You can check out VutaImage complete documentation here Click Here.
To showcase how VutaImage works, we first create a new Android project. In this article I am not going to explain how to create an Android project but I assume that you already know how to. If you don’t, follow the steps from this link (http://www.tutorialspoint.com/android/android_hello_world_example.htm) then continue from here.
- Since we will be accessing files from an external link/remote server, we need to declare this permission in the project’s AndroidManifest.xml, Also we need to add permission to write to external storage because we will be writing files to phones sdcard. Open your project manifest file and add these permissions between the <uses-sdk …/> [....here...] <application …/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
- After that we add the VutaImage library to the project. To do that you can use these two ways.
- Cloning from Github project – Download VutaImage project from the github project page https://github.com/bmutinda/VutaImage, import VutaImage-Library to your workspace as an Android Project. Once the project has been imported successfully, right click the project VutaImage, go to properties->Android then on Library panel..click Is Library checkbox.
Go to your project, right click , go to properties->Android then on Library panel Click Add, then select VutaImage in the list of the available libraries. Click Apply then Ok.
- Using library Jar file Recommended. Download the latest jar file from http://bmutinda.github.io/VutaImage/ copy the jar file to your project’s libs folder, right click the imported jar file, select build path then click add to build path.
Hooray!! , you now have the VutaImage library ready to be used in your project.
NB: If you face any problem setting up VutaImage library, you can head direct to its website ( http://bmutinda.github.io/VutaImage/ ) for a complete documentation.
Next I will show you how to download a single image or multiple images with one API call bundled with callbacks for each state of download.
To download a single image – Continue in Part 2