Android - store image on a temp file cross-activity
<p>In the app I am developing, I have an activity in which I show two <strong>ImageViews</strong> made of two bitmaps, <code>ca.bm</code> and <code>ca.tempBm</code> respectively. It works fine on my device but produces <strong>OutOfMemoryError</strong> on some devices when trying to copy the original bitmap to the bitmap I will modify later:</p>

<pre><code>ca.tempBm = Bitmap.createBitmap(ca.bm);   // out of memory error
</code></pre>

<p>I would like to create a temp file instead to hold the original image and work with a single bitmap, but the temp file must be preserved when changing from the Camera Activity to the next activity and should be destroyed only when the second activity does.</p>

<p>How can I achieve this?</p>