0

I want download some images from an android application, and then show these images.

I want know where I have to put my downloaded images and how to refer to them in order to show them, for example using them as background of a View object.

GVillani82
  • 17,196
  • 30
  • 105
  • 172
  • How are you downloading? Do you have any code you can show us, so we may better help or have an idea of what you are trying to accomplish and how? – jnthnjns Nov 06 '12 at 14:44
  • I can download any file and I can put it everywhere I want. But I don't know how to refer to this image. – GVillani82 Nov 06 '12 at 14:47
  • Yes, I can download any file to. What I am asking is HOW you are downloading and where are you getting them from. Are you retrieving from a MySQL database through `AsyncTask`?... etc – jnthnjns Nov 06 '12 at 14:48
  • maybe I have to change my question. The download is not the problem. Immagine that the images I want show are yet on file system. (in any path) What can I do for getting an image from file system and use it as background of a certain view? – GVillani82 Nov 06 '12 at 14:52

1 Answers1

3

Here is an example of downloading an image from a URL and showing it in an ImageView.

This is the download method:

void downloadFile(String fileUrl) {
try{
  InputStream is = (InputStream) new URL(fileUrl).getContent();
  Drawable d = Drawable.createFromStream(is, "src name");
  imgView.setImageDrawable(d);            
    } catch (IOException e) {
        e.printStackTrace();                
    }

}
Community
  • 1
  • 1
Jong
  • 9,045
  • 3
  • 34
  • 66