To upload an image I use:
downloadImage
public static Bitmap downloadImage(String iUrl) { Bitmap bitmap = null; HttpURLConnection conn = null; BufferedInputStream buf_stream = null; try { Log.v(TAG, "Starting loading image by URL: " + iUrl); conn = (HttpURLConnection) new URL(iUrl).openConnection(); conn.setDoInput(true); conn.setRequestProperty("Connection", "Keep-Alive"); conn.connect(); buf_stream = new BufferedInputStream(conn.getInputStream(), 8192); bitmap = BitmapFactory.decodeStream(buf_stream); buf_stream.close(); conn.disconnect(); buf_stream = null; conn = null; } catch (MalformedURLException ex) { Log.e(TAG, "Url parsing was failed: " + iUrl); } catch (IOException ex) { Log.d(TAG, iUrl + " does not exists"); } catch (OutOfMemoryError e) { Log.w(TAG, "Out of memory!!!"); return null; } finally { if ( buf_stream != null ) try { buf_stream.close(); } catch (IOException ex) {} if ( conn != null ) conn.disconnect(); } return bitmap; } To update the listview
try {JSONObject jsonResponse = new JSONObject (response.toString ()); JSONArray jsonMainNode = jsonResponse.getJSONArray ("items"); // JSONArray Data = jsonResponse.getJSONArray ("snippet");
for(int i = 0; i<jsonMainNode.length();i++){ JSONObject jsonChildNode = jsonMainNode.getJSONObject(i); String name = jsonChildNode.optString("kind"); String number = jsonChildNode.optString("etag"); JSONObject item = jsonMainNode.getJSONObject(i); JSONObject snippet = item.getJSONObject("snippet"); String title = snippet.getString("title"); String channelTitle = snippet.getString("channelTitle"); String pubDate = snippet.getString("publishedAt"); JSONObject thumbs = snippet.getJSONObject("thumbnails"); JSONObject thumb = thumbs.getJSONObject("default"); final String ico = thumb.getString("url"); new Thread(new Runnable() { public void run() { bmp = ImageManager.downloadImage(ico); } }).start(); countryList.add(createEmployee(title,channelTitle,pubDate, bmp)); } simpleAdapter.notifyDataSetChanged(); Listview update occurs, but it does not load pictures. Update ListView occurs on the button