title: Using the Internal Storage - Android - Deleting Cache Files
body: <p>I am downloading images and then saving them to the internal memory. This has a result the cache of the app to grow very quickly.</p>
  
  <p>As it is suggested here:</p>
  
  <p><a href="http://developer.android.com/guide/topics/data/data-storage.html" rel="nofollow">http://developer.android.com/guide/topics/data/data-storage.html</a></p>
  
  <p><em>When the device is low on internal storage space, Android may delete these cache files to recover space. However, you should not rely on the system to clean up these files for you. You should always maintain the cache files yourself and stay within a reasonable limit of space consumed, such as 1MB</em></p>
  
  <p>My question is what will happen if the cache gets too big, for example now is around 20mb and is still growing.</p>
  
  <p>I thought that I should follow the guidelines and delete them each time my app starts if internet connection is available.</p>
  
  <pre><code> String[] allFiles =  fileList();
  
   Log.e(TAG, "allFiles.length: " + allFiles.length);
  
  
   for(int k=0; k&lt;allFiles.length; k++)
   {
   Log.e(TAG, "allFiles [ " +k+"]: "+allFiles[k]);
  
   }
  </code></pre>
  
  <p>However, this code always return zero files. If i try to access a specific image I can easily retrieve it from the internal memory. Why this code cannot return an array with all my images??</p>
  
  <p>What is the right approach to follow for the internal memory..</p>
  
  <p>Thanks in advance,</p>
  
  <p>Andreas</p>