views:

61

answers:

3

I have an array of all the URIs of the images which I am showing in a List. Now I want to run a thread in background which gets this images from web and store them on the SD card. So when I click a particular element in the list instead of fetching from web it should fetch from the SD card in the new activity.

How do I do this?

A: 

You should probably tell us more about what you've got so far - what you've tried and what's not working for you.

In the meantime, this might help: http://android-developers.blogspot.com/2010/07/multithreading-for-performance.html

Scott Saunders
A: 

Check WebImageView by matthias käppler.

You can replace his way of caching images with the SDcard feature you want.

Macarse
A: 

Use AsyncTask download in the background while show your UI

    File imageFile;

Save Images from web

public View getView(int position, View convertView, ViewGroup parent) {    
    imageFile = new File("/sdcard/jorgesysTemp/" + Arraypicname(position);
    if(!imageFile.exists()){ 
     AsyncTaskProcess() //Download your images to sdcard
    }

When you click your listview load the image from sdcard

    @Override
    protected void onListItemClick(ListView l, View v, final int position, long id) {
     //load from sdcard
        Bitmap bitmapImg = BitmapFactory.decodeFile("/sdcard/jorgesysTemp/" + Arraypicname(position));
        BitmapDrawable drawableImg = new BitmapDrawable(bitmapImg );                
        myimageview.setImageDrawable(drawableImg );
...
...
...     
Jorgesys