Hello friends welcome to one more Android Programming Tutorial. In the last couple of Android Development Tutorial posts we have seen uploading image from android gallery to MySQL database. And fetching images from MySQL database to android. In this android app tutorial we will fetch all the images stored in our MySQL database at once.
Before going further in this tutorial you should check the last android programming tutorials.
If you have already read the last android programming tutorial then lets move ahead.
Lets Start our Android Programming Tutorial
- We will be using the same database, where we have already uploaded some images. My database is as follows.

- As you can see our database has images.
- Now we will create a simple php script to get the live URL of all the images in our database.
- for getting the URL we will use our getImage.php script which we have created in last tutorial.
- We can get a particular image using our getImage.php, with a simple get request. For example if we want to get image of id 31 we will execute our getImage.php like -> getImage.php?id=31.
- But in this tutorial we will have to get all the images at once. So we will create a new script to get all the images.
- Create a php file and copy the following code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | <?php require_once('dbConnect.php'); $sql = "select id from images"; $res = mysqli_query($con,$sql); $result = array(); $url = "http://simplifiedcoding.16mb.com/ImageUpload/getImage.php?id="; while($row = mysqli_fetch_array($res)){ array_push($result,array('url'=>$url.$row['id'])); } echo json_encode(array("result"=>$result)); mysqli_close($con); |
- As you can see in the above code we have the url of our getImage.php. And inside the loop we are concatenating ids of the image at the end and storing it to an array.
- The loop will store url of all the images inside our array.
- And finally we are encoding the array in json format.
- We will read the json from Android.
- Save the above file and upload it to your hosting account. In my case I have uploaded it to http://simplifiedcoding.16mb.com/ImageUpload/getAllImages.php
- If we go to the above given URL we will see the JSON as follows
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | { "result": [ { "url": "http://simplifiedcoding.16mb.com/ImageUpload/getImage.php?id=6" }, { "url": "http://simplifiedcoding.16mb.com/ImageUpload/getImage.php?id=7" }, { "url": "http://simplifiedcoding.16mb.com/ImageUpload/getImage.php?id=8" }, { "url": "http://simplifiedcoding.16mb.com/ImageUpload/getImage.php?id=29" }, { "url": "http://simplifiedcoding.16mb.com/ImageUpload/getImage.php?id=31" }, { "url": "http://simplifiedcoding.16mb.com/ImageUpload/getImage.php?id=32" }, { "url": "http://simplifiedcoding.16mb.com/ImageUpload/getImage.php?id=33" }, { "url": "http://simplifiedcoding.16mb.com/ImageUpload/getImage.php?id=34" } ] } |
Creating a new Android Project
- Create a new Android Project.
- In activity_main.xml we have to create the following layout.

- The above layout has three buttons and one image view. You can use the following xml code to create the above layout.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:orientation="vertical" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Fetch Images" android:id="@+id/buttonFetchImages" /> <ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:id="@+id/imageView" /> <LinearLayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Previous" android:layout_weight="1" android:id="@+id/buttonPrev" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Next" android:layout_weight="1" android:id="@+id/buttonNext" /> </LinearLayout> </LinearLayout> |
- Now lets move to your MainActivity.java file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | public class MainActivity extends AppCompatActivity implements View.OnClickListener { private static final String IMAGES_URL = "http://www.simplifiedcoding.16mb.com/ImageUpload/getAllImages.php"; private Button buttonFetchImages; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); buttonFetchImages = (Button) findViewById(R.id.buttonFetchImages); buttonFetchImages.setOnClickListener(this); } @Override public void onClick(View v) { if(v == buttonFetchImages) { getAllImages(); } } } |
- As you can see we have implemented View.OnClickListener interface. Created our button and added the listener to the button. We also declared a String having the URL of our getAllImages.php file.
- Now we need to create the getAllImages() method.
- This is our getAllImages method.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | private void getAllImages() { class GetAllImages extends AsyncTask<String,Void,String>{ ProgressDialog loading; @Override protected void onPreExecute() { super.onPreExecute(); loading = ProgressDialog.show(MainActivity.this, "Fetching Data","Please Wait...",true,true); } @Override protected void onPostExecute(String s) { super.onPostExecute(s); loading.dismiss(); Toast.makeText(MainActivity.this,s,Toast.LENGTH_LONG).show(); } @Override protected String doInBackground(String... params) { String uri = params[0]; BufferedReader bufferedReader = null; try { URL url = new URL(uri); HttpURLConnection con = (HttpURLConnection) url.openConnection(); StringBuilder sb = new StringBuilder(); bufferedReader = new BufferedReader(new InputStreamReader(con.getInputStream())); String json; while((json = bufferedReader.readLine())!= null){ sb.append(json+"\n"); } return sb.toString().trim(); }catch(Exception e){ return null; } } } GetAllImages gai = new GetAllImages(); gai.execute(IMAGES_URL); } |
- So the above code is very simple, we are using AsyncTask to read our JSON. And after reading we are displaying the json in a toast message. We are displaying json in toast only to check that json have been read or not. We will remove this toast further. But for now lets check whether the json is being read successfully or not.
- Now add internet permission to your manifest and run the project.
1 2 3 | <uses-permission android:name="android.permission.INTERNET"/> |
- If you are getting the json string in a toast message after pressing fetch all images button then your project is working fine and you can move ahead. You should see the following output.

Converting JSON to Images
- Remove the Toast Message.
- We need some more components, so declare the following inside your MainActivity.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | public class MainActivity extends AppCompatActivity implements View.OnClickListener { private String imagesJSON; private static final String JSON_ARRAY ="result"; private static final String IMAGE_URL = "url"; private JSONArray arrayImages= null; private int TRACK = 0; private static final String IMAGES_URL = "http://www.simplifiedcoding.16mb.com/ImageUpload/getAllImages.php"; private Button buttonFetchImages; private Button buttonMoveNext; private Button buttonMovePrevious; private ImageView imageView; |
- Inside onCreate, initialize them and add listeners to buttons.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); imageView = (ImageView) findViewById(R.id.imageView); buttonFetchImages = (Button) findViewById(R.id.buttonFetchImages); buttonMoveNext = (Button) findViewById(R.id.buttonNext); buttonMovePrevious = (Button) findViewById(R.id.buttonPrev); buttonFetchImages.setOnClickListener(this); buttonMoveNext.setOnClickListener(this); buttonMovePrevious.setOnClickListener(this); } |
- Now we will create a getImage method. This method will take a string as a parameter. The string would have the url to image extracted from json array.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | private void getImage(String urlToImage){ class GetImage extends AsyncTask<String,Void,Bitmap>{ ProgressDialog loading; @Override protected Bitmap doInBackground(String... params) { URL url = null; Bitmap image = null; String urlToImage = params[0]; try { url = new URL(urlToImage); image = BitmapFactory.decodeStream(url.openConnection().getInputStream()); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return image; } @Override protected void onPreExecute() { super.onPreExecute(); loading = ProgressDialog.show(MainActivity.this,"Downloading Image...","Please wait...",true,true); } @Override protected void onPostExecute(Bitmap bitmap) { super.onPostExecute(bitmap); loading.dismiss(); imageView.setImageBitmap(bitmap); } } GetImage gi = new GetImage(); gi.execute(urlToImage); } |
- Now we will create two more methods. The first one to extract json and other one to show image.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | private void extractJSON(){ try { JSONObject jsonObject = new JSONObject(imagesJSON); arrayImages = jsonObject.getJSONArray(JSON_ARRAY); } catch (JSONException e) { e.printStackTrace(); } } private void showImage(){ try { JSONObject jsonObject = arrayImages.getJSONObject(TRACK); getImage(jsonObject.getString(IMAGE_URL)); } catch (JSONException e) { e.printStackTrace(); } } |
- We need to make some little changes in our getAllImages method.
- Inside onPostExecute we have to call the extractJSON and showImage() method.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | private void getAllImages() { class GetAllImages extends AsyncTask<String,Void,String>{ ProgressDialog loading; @Override protected void onPreExecute() { super.onPreExecute(); loading = ProgressDialog.show(MainActivity.this, "Fetching Data...","Please Wait...",true,true); } @Override protected void onPostExecute(String s) { super.onPostExecute(s); loading.dismiss(); imagesJSON = s; extractJSON(); showImage(); } @Override protected String doInBackground(String... params) { String uri = params[0]; BufferedReader bufferedReader = null; try { URL url = new URL(uri); HttpURLConnection con = (HttpURLConnection) url.openConnection(); StringBuilder sb = new StringBuilder(); bufferedReader = new BufferedReader(new InputStreamReader(con.getInputStream())); String json; while((json = bufferedReader.readLine())!= null){ sb.append(json+"\n"); } return sb.toString().trim(); }catch(Exception e){ return null; } } } GetAllImages gai = new GetAllImages(); gai.execute(IMAGES_URL); } |
- Now at last we need to create two more methods to display the next or previous image.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | private void moveNext(){ if(TRACK < arrayImages.length()){ TRACK++; showImage(); } } private void movePrevious(){ if(TRACK>0){ TRACK--; showImage(); } } |
- Now finally call these methods inside onClick.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | @Override public void onClick(View v) { if(v == buttonFetchImages) { getAllImages(); } if(v == buttonMoveNext){ moveNext(); } if(v== buttonMovePrevious){ movePrevious(); } } |
- You can see the final complete code below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | package net.simplifiedcoding.getallimages; import android.app.ProgressDialog; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.os.AsyncTask; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.ImageView; import android.widget.Toast; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; public class MainActivity extends AppCompatActivity implements View.OnClickListener { private String imagesJSON; private static final String JSON_ARRAY ="result"; private static final String IMAGE_URL = "url"; private JSONArray arrayImages= null; private int TRACK = 0; private static final String IMAGES_URL = "http://www.simplifiedcoding.16mb.com/ImageUpload/getAllImages.php"; private Button buttonFetchImages; private Button buttonMoveNext; private Button buttonMovePrevious; private ImageView imageView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); imageView = (ImageView) findViewById(R.id.imageView); buttonFetchImages = (Button) findViewById(R.id.buttonFetchImages); buttonMoveNext = (Button) findViewById(R.id.buttonNext); buttonMovePrevious = (Button) findViewById(R.id.buttonPrev); buttonFetchImages.setOnClickListener(this); buttonMoveNext.setOnClickListener(this); buttonMovePrevious.setOnClickListener(this); } private void extractJSON(){ try { JSONObject jsonObject = new JSONObject(imagesJSON); arrayImages = jsonObject.getJSONArray(JSON_ARRAY); } catch (JSONException e) { e.printStackTrace(); } } private void showImage(){ try { JSONObject jsonObject = arrayImages.getJSONObject(TRACK); getImage(jsonObject.getString(IMAGE_URL)); } catch (JSONException e) { e.printStackTrace(); } } private void moveNext(){ if(TRACK < arrayImages.length()){ TRACK++; showImage(); } } private void movePrevious(){ if(TRACK>0){ TRACK--; showImage(); } } private void getAllImages() { class GetAllImages extends AsyncTask<String,Void,String>{ ProgressDialog loading; @Override protected void onPreExecute() { super.onPreExecute(); loading = ProgressDialog.show(MainActivity.this, "Fetching Data...","Please Wait...",true,true); } @Override protected void onPostExecute(String s) { super.onPostExecute(s); loading.dismiss(); imagesJSON = s; extractJSON(); showImage(); } @Override protected String doInBackground(String... params) { String uri = params[0]; BufferedReader bufferedReader = null; try { URL url = new URL(uri); HttpURLConnection con = (HttpURLConnection) url.openConnection(); StringBuilder sb = new StringBuilder(); bufferedReader = new BufferedReader(new InputStreamReader(con.getInputStream())); String json; while((json = bufferedReader.readLine())!= null){ sb.append(json+"\n"); } return sb.toString().trim(); }catch(Exception e){ return null; } } } GetAllImages gai = new GetAllImages(); gai.execute(IMAGES_URL); } private void getImage(String urlToImage){ class GetImage extends AsyncTask<String,Void,Bitmap>{ ProgressDialog loading; @Override protected Bitmap doInBackground(String... params) { URL url = null; Bitmap image = null; String urlToImage = params[0]; try { url = new URL(urlToImage); image = BitmapFactory.decodeStream(url.openConnection().getInputStream()); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return image; } @Override protected void onPreExecute() { super.onPreExecute(); loading = ProgressDialog.show(MainActivity.this,"Downloading Image...","Please wait...",true,true); } @Override protected void onPostExecute(Bitmap bitmap) { super.onPostExecute(bitmap); loading.dismiss(); imageView.setImageBitmap(bitmap); } } GetImage gi = new GetImage(); gi.execute(urlToImage); } @Override public void onClick(View v) { if(v == buttonFetchImages) { getAllImages(); } if(v == buttonMoveNext){ moveNext(); } if(v== buttonMovePrevious){ movePrevious(); } } } |
Video Demo of Final Output
You can check this video demonstration of what we have created in this tutorial.
Download Source code of this Android Programming Tutorial
If you are having trouble in creating the app shown in this Android Programming Tutorial. Download the source code from the link given below
[easy_media_download url=”https://dl.dropboxusercontent.com/s/su8raogxy4w3kwf/android-programming-tutorial-get-all-images-from-server.zip?dl=0″ text=”Download Source”]
To display all the images in a List check this tutorial
So thats all for this Android Programming Tutorial friends. If you want to learn more about android application development you can go through the official android developers website. And leave your comments for any kind of queries. Thank You 🙂

Hi, my name is Belal Khan and I am a Google Developers Expert (GDE) for Android. The passion of teaching made me create this blog. If you are an Android Developer, or you are learning about Android Development, then I can help you a lot with Simplified Coding.
Hi Belal,
How to show this record on list view that will show all the records with image rather than click next and previous?
stay tuned you will get a tutorial for doing this
Thanks Belal,
If possible show us list view that will have some data and blob images from mysql db.
It will be really helpful for all students and developers 🙂
Thanks Belal,
please upload a tutorial fetching images of blob and text from database to a listView . That would be very helpful
Thanks Belal,
Your article help me a lot.
I also have the same question of fetching images of blob from database to a listView too.
here is your answer I just published a new tutorial for your query
http://www.simplifiedcoding.net/android-upload-image-using-php-mysql-android-studio/
cheers (y)
Can you explain to me the part of the code where you convert the BLOB datatype to ImageView?
Thanks for this tutorial 🙂
but there is a problem with me
json string can’t read in Toast
the toast appear empty
any help please
If you are using wamp/xampp server then check that server is accessible by your emulator? by opening the fetch json script from emulator browsers
and where is your getImage.php file? I mean what should we write there as to get Image.
you should check the previous tutorial to know about getImage.php file
http://www.simplifiedcoding.net/android-download-image-from-server-using-php-and-mysql/
you will get getImage.php from here
Thank You Belal Khan. One Problem i am not getting images in Android App.
my php code is:
$con = mysql_connect(“localhost”,”root”,””);
$selc_db = mysql_select_db(“school”,$con);
//if($_SERVER[‘REQUEST_METHOD’]==’GET’){
$id = $_GET[‘id’];
$sql = “select * from image where id = ‘”.$id.”‘”;
//echo $id.”.$sql;
$r = mysql_query($sql);
$result = mysql_fetch_array($r);
header(‘content-type: image/jpeg’);
echo base64_decode($result[‘img’]);
mysql_close($con);
//}
//else{
echo ‘Error’;
//}
you are using deprecated php methods.. check my php code.. and correct it accordingly
Thank you very much for all codes .. reallly appreciated!
You have a code for showing images in a listView where these images are saved in a folder and you have this code where images are saved in the database itself and you are showing one at a time.
Can you do a code where you retrieve images from Database and show them in a listView?
check the other tutorials may be that help
Dear sir, may I know how can I make it to display all image the moment I open the apps instead of pressing the button to display the image?
Appreciate and looking forward for ur reply 😀
Check these tutorials
https://www.simplifiedcoding.net/android-upload-image-using-php-mysql-android-studio/
https://www.simplifiedcoding.net/android-custom-listview-with-images-using-recyclerview-and-volley/
Dear sir, sorry for disturb 🙁 i encounter app crash after i click fetch images
11-29 03:29:10.271 20974-20974/com.example.clementchen.androidimageupload E/AndroidRuntime: FATAL EXCEPTION: main
11-29 03:29:10.271 20974-20974/com.example.clementchen.androidimageupload E/AndroidRuntime: Process: com.example.clementchen.androidimageupload, PID: 20974
11-29 03:29:10.271 20974-20974/com.example.clementchen.androidimageupload E/AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method ‘org.json.JSONObject org.json.JSONArray.getJSONObject(int)’ on a null object reference
11-29 03:29:10.271 20974-20974/com.example.clementchen.androidimageupload E/AndroidRuntime: at com.example.clementchen.androidimageupload.ViewAll.showImage(ViewAll.java:77)
11-29 03:29:10.271 20974-20974/com.example.clementchen.androidimageupload E/AndroidRuntime: at com.example.clementchen.androidimageupload.ViewAll.access$200(ViewAll.java:28)
11-29 03:29:10.271 20974-20974/com.example.clementchen.androidimageupload E/AndroidRuntime: at com.example.clementchen.androidimageupload.ViewAll$1GetAllImages.onPostExecute(ViewAll.java:118)
11-29 03:29:10.271 20974-20974/com.example.clementchen.androidimageupload E/AndroidRuntime: at com.example.clementchen.androidimageupload.ViewAll$1GetAllImages.onPostExecute(ViewAll.java:100)
11-29 03:29:10.271 20974-20974/com.example.clementchen.androidimageupload E/AndroidRuntime: at android.os.AsyncTask.finish(AsyncTask.java:632)
11-29 03:29:10.271 20974-20974/com.example.clementchen.androidimageupload E/AndroidRuntime: at android.os.AsyncTask.access$600(AsyncTask.java:177)
11-29 03:29:10.271 20974-20974/com.example.clementchen.androidimageupload E/AndroidRuntime: at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
11-29 03:29:10.271 20974-20974/com.example.clementchen.androidimageupload E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
11-29 03:29:10.271 20974-20974/com.example.clementchen.androidimageupload E/AndroidRuntime: at android.os.Looper.loop(Looper.java:145)
11-29 03:29:10.271 20974-20974/com.example.clementchen.androidimageupload E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5832)
11-29 03:29:10.271 20974-20974/com.example.clementchen.androidimageupload E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
11-29 03:29:10.271 20974-20974/com.example.clementchen.androidimageupload E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:372)
11-29 03:29:10.271 20974-20974/com.example.clementchen.androidimageupload E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
11-29 03:29:10.271 20974-20974/com.example.clementchen.androidimageupload E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
the main problem is
java.lang.NullPointerException: Attempt to invoke virtual method ‘org.json.JSONObject org.json.JSONArray.getJSONObject(int)’ on a null object reference
the problem above had solved but currently, another problem arise 🙁
After i clicked fetch image then click next button, no photo is showing
How you solve that problem
thanks for code…but my app is not fetching images from server…
02-05 10:56:07.897 17299-17299/com.example.mundk.showimage E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.NullPointerException
at com.example.mundk.showimage.MainActivity.showImage(MainActivity.java:55)
at com.example.mundk.showimage.MainActivity.access$200(MainActivity.java:24)
at com.example.mundk.showimage.MainActivity$1GetAllImages.onPostExecute(MainActivity.java:77)
at com.example.mundk.showimage.MainActivity$1GetAllImages.onPostExecute(MainActivity.java:63)
at android.os.AsyncTask.finish(AsyncTask.java:631)
at android.os.AsyncTask.access$600(AsyncTask.java:177)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5041)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
Sir need help how to solve the problem please
hello thanks for the tutorial
how would you put all of the images in a listview
how do i put the images into a listview
Hi , I want to ask what should we put instead of your url ?
Thanks for a good thing, y know it just amazing job man.. but i need to show in galleryview all images any idea to make possible? any suggesstion?
I want to retrieve images from sql server. My images are stored in image datatype. I want to show it on my android app…. which concept should I use. Please guide…
I want to retrieve images from sql server. My images are stored in image datatype. I want to show it on my android app…. which concept should I use. Please guide..
Hi,
I have tried the code image is uploaded to database bur when i try to fetch all images it shows downloading but after that there is no image in imageView. Same problem in both the getAllImages and getImage. please tell me solution what should I have to do.
I had uploaded images to local database.
Thanks and Regards,
Avinash Yadav
avinashsy143@gmail.com
In this code you do not call getItem() method ??where I need to do that??
Sorry for this I found it
///////In my doInBackground method as follows////
@Override
protected Bitmap doInBackground(String… params) {
URL url = null;
Bitmap image = null;
String urlToImage = params[0];
System.out.println(“XXXXXXXXXXXXXXXXXXXX”+urlToImage);
try {
url = new URL(urlToImage);
image = BitmapFactory.decodeStream(url.openConnection().getInputStream());
System.out.println(“iiiiiiiiiiiiiiiiiiiiii”+image);
} catch (MalformedURLException e) {
e.printStackTrace();
}
catch (Exception e) {
e.printStackTrace();
}
return image;
}
In here I get urlToImage as “http://codex.site88.net/getImages.php?Title=GangaramaTemple” but in image value print as null.
Please tell me what I want to do fix this?
All issues was came due to my careless mistakes.Code is working fine.Thank u so much…
SkImageDecoder::Factory Returned null
How Did You Solve It?
Please Do Reply
What was your fix?
Please sir, i need help everything went fine when i displayed with toast but afterward, my imageview didn’t display the image, but the dialog box was shown downloading image i need help
can we upload the images manually into the database table?
After i clicked fetch image then click next button, no photo is showing
Please Sir,i need your help. I can get the json string in a toast message after pressing fetch all images button but there is no image on the imageView. Please help me!! THANK YOU
very good hellpfull
Hey, images are not being displayed….and i followed the exact steps you used… any ideas what might be the problem?
Can you explain to me the part of the code where you convert the BLOB datatype to ImageView?What is the code on getImage.php is very much required!I tried myself with a tutorial and it is failing.
private void showImage(){
try {
JSONObject jsonObject = arrayImages.getJSONObject(TRACK); //Error line
getImage(jsonObject.getString(IMAGE_URL));
} catch (JSONException e) {
e.printStackTrace();
}
}
Error is :
java.lang.NullPointerException: Attempt to invoke virtual method ‘org.json.JSONObject org.json.JSONArray.getJSONObject(int)’ on a null object reference
Hello Can help me one case:
If the database contains a table and table has a column having varbinary image data. How I can generate taht image in android studio after fetching that varbinary image data. I can fetch the varbinary image data through HTTP but can’t use that in android studio to show that image by converting base64 string.
If you have any suggestion would be very much pleased.
when i click on fetch images button it will get stop what should i do
when i press fetch button my app suddenly close. Why?