Question: I am new to using `ArrayList`'s in java. I have several lists and want to write a method for removing a list with its elements. Here is what I have so far:

```
public void delete(double value){
    list.remove(value);
}

```

After that I want get the output:

```
public ArrayList<Double> getlist(){
    return list;
}

```

Answer: 
How long does the loading of images take? If it's negligible then why not load each image in right before you display it, discarding the old one? That way you only have 1 image in memory at any one stage. 

Alternatively do something akin to using a back buffer, have two spaces in memory, one for the image being displayed now, an another into which you're loading the next image. When it's time to change you make the newly loaded bitmap visible, unload the other and then load the next frame into that.
Despite what people say, you actually can have a lot of images in your Live Wallpaper. The only tricky thing is the memory limit. I had as much as 40 .pngs loaded in my application and i reloaded them once in a minute. 

But when you handling that many images in your application, you have to load them in a smart way:

```
public BitmapResult decodeResource(int file, int scale){
        //Decode image size
        BitmapFactory.Options o = new BitmapFactory.Options();
        o.inPurgeable = true;
        o.inInputShareable = true;
        o.inJustDecodeBounds = true;
        BitmapFactory.decodeResource(resources, file, o);

        BitmapFactory.Options o2 = new BitmapFactory.Options();
        o2.inPreferredConfig = Bitmap.Config.ARGB_8888;
        o2.inSampleSize=scale;
        return new BitmapResult(BitmapFactory.decodeResource(resources, file, o2),o2.outWidth,o2.outHeight);
}

```

You see that scale variable? It should be a power of 2 and it scales your bitmap down. 

In case things got wrong, clean the bitmaps and reload bitmaps with a lower quality:

```
void init()
{
    try
    {
         loadFirstBitmap();
         loadSecondBitmap();
    }
    catch(java.lang.OutOfMemoryError error)
    {
         /*some infinite loop breaker*/
         scale *= 2;
         cleanup();
         init();
    }
}

```

Also, system won't get rid of a bitmaps for you, you have to clean them yourself and then probably call the garbage collector:

```
bitmap1.recycle();
bitmap2.recycle();
System.gc();

```

Resizing your bitmaps to the size you need is also a good idea because otherwise system would probably call createScaledBitmap each time you try to draw it which would require additional memory. 

I never figured what's the memory cap for such kind of apps is and is it that a memory heap limit which most often equals 24 MB, but i can tell you that my app takes up to 13 MB of memory and no one ever reported a crash on Android devices >= 2.2.

So if you follow some optimization rules, you can load as much bitmaps in your application as you need.