Android - Design Pattern for Storing Indeterminate Amounts and Sizes of Images
<p>I am trying to decide where to store images that are sent as part of instant messages coming in to an app.  These messages are viewable in a conversation history view for sometimes a significant period of time after their original receipt.  You can imagine any number of other use cases that would have a similar requirement, so the question here is on the "best practice for storing an indeterminate quantity and size of images"</p>

<p><strong>Assumptions</strong></p>

<ul>
<li>SQLite storage is clearly a bad option since the image size is not
bounded.</li>
<li>It is neither desirable nor undesirable that these images be publicly available to other apps or discoverable by MediaScanner.  We are assumed to be perfectly neutral on this point...</li>
</ul>

<p>This leaves two parts to this question:</p>

<p><strong>1.  External Storage</strong></p>

<p>It seems like external storage is to be preferred when available because it is likely to have more room than anything else: </p>

<p>The documentation says the following:</p>

<blockquote>
  <p>...use getExternalCacheDir() to
  open a File that represents the external storage directory where you
  should save cache files. If the user uninstalls your application,
  these files will be automatically deleted. However, during the life of
  your application, you should manage these cache files and remove those
  that aren't needed in order to preserve file space.</p>
</blockquote>

<p>Unlike internal storage cache, there is no statement made about the automatic reclamation of space on external storage by Android.  Still the word "cache" makes me nervous.</p>

<ul>
<li><em>Question 1:</em> Do these files remain until explicitly deleted regardless?</li>
<li><em>Question 2:</em> Is there any other external storage other than the cache that is automatically deleted upon app uninstall AND is preferable to the external cache for some specific reason?</li>
</ul>

<p><strong>2.  Internal Storage</strong></p>

<p>Clearly not every device has external storage, so there needs to be a provision for internal storage.</p>

<ul>
<li><em>Question 3:</em> Is the only practical difference between the internal cache retrieved through <code>getCacheDir()</code> and files created with <code>openFileOutput(FILENAME, Context.MODE_PRIVATE)</code> that Android may delete files in the cache directory when under pressure for storage space?</li>
</ul>
