Download Complete Source Code of the Android download Image App


How this App looks like on Android Phone?

Android Image Download App

Before start with the coding part, you need to read some instructions first.

1) Use Android Studio.

2) Use MSSQL Server.

3) Firewal must allow to connect to database. (or turn off firewall from control pannel)

4) Download and add version of jtds 1.2.7 jar file and you have to include it in your project. If you donot know how to include a Jar file, See how to include jtds jar file to your project HERE.
Becuase we are going to connect with the Mssql server using library provided, named as JDBC. So you must need to include this file into your project correctly. Without this library you won't be able to connect to the server.

5) There should be an image in your database inserted already, because we are going to retrieve an image from the database. If you don't have already inserted an image from the database then take a look at my This tutorial so that you could insert image in database first.

6) Remember, if for inserting the image in the database you have followed my tutorial then I inserted the image in Base64. So, this tutorial will show you how to download image of base64 string from database.

7) You need to modify the database connection variables and the query string according to your need.

8) Follow all steps and read them carefully.

Let's get Started...

Your Jar file should look like this
download image Jar addition

After following all the steps above, Open your App gradle module and add the following line into it


build.gradle (Module App)

Like this screenshot below:

download image app gradle

Now, Open your activity_main.xml and add the following code to the layout


activity_main.xml


After adding this XML to your app, Your app design would look like this:

Donwload Image App

Now, Open your AndroidManifest.xml file and add the following internet and storage permission

AndroidManifest.xml


By Adding this, Your Manifest file looks like this:
Download Image Android manifest file

Now, open your MainActiviy.java and replace the java code without package name.
Make sure that you need to change the database credentials and the query string according to your own database structure


MainActivity.java


Screenshots of the App before and after fetching image from the Server:


Android Image Download App Android Image Download App

Click To Download Complete Source Code of the Android Download Image App