Code example for URLConnection

Methods: getContent, setUseCaches

0
	 
    private Bitmap fetch(String urlString) throws MalformedURLException, IOException {
    	Bitmap bitmap = null;
    	URL url = new URL(urlString);
    	URLConnection connection = url.openConnection();
    	connection.setUseCaches(true);
    	Bitmap response = BitmapFactory.decodeStream((InputStream) connection.getContent());
    	if(response instanceof Bitmap){
    		 bitmap = (Bitmap)response;
    	} 
    	return bitmap;
    } 
     
    public void queueDrawableFetch(final String urlString, final ImageView imageView) {
    	if (urlString == null || urlString.equals("")) {
    		if (imageView != null)
    			imageView.setImageResource(android.R.drawable.btn_star);
    		return; 
    	} else 
    		if (imageView.getTag() == null)
				imageView.setTag(urlString);