Android. OutOfMemory problems
<p>I require displaying many images in my application. These being jpgs and pngs and i'm loading them inside ImageViews like so:</p>

<pre><code>tile.setImageResource(R.drawable.tile_highlight);
</code></pre>

<p>I am currently having OutOfMemory problems (<code>java.lang.OutOfMemoryError: bitmap size exceeds VM budget</code>)</p>

<p>I've searched and found some other posts, they all suggest that you should recycle the bitmap of an ImageView manually, like so: <code>((BitmapDrawable)imageView.getDrawable()).getBitmap().recycle();</code> which will dump it from memory.</p>

<p>BUT in my case, being that i'm not using <code>setBitmap()</code> to load the images onto the ImageView objects, when i try and run the above code, it returns <code>NullPointerException</code>, more precisely, the method <code>getBitmap()</code> returns null, there is no bitmap ?!?!</p>

<p>Do i need to go back in my code and change the way i load all the images in the ImageViews, and then try with the <code>recycle()</code> method? Or how can i free up the memory so it doesn't crash anymore?</p>

<p><strong>EDIT</strong></p>

<p>I've tried something like so: <code>imageView.setImageResource(-1);</code> in hopes it will remove the image from memory and replace it with ... null or something, but it seems it doesn't help the cause.</p>
