title: Permissions for getExternalCacheDir() and getCacheDir()
body: <p>my http library is caching http responses. My current implementation to select the directory where to cache the data looks like this:</p>
  
  <pre><code>public static File getDiskCacheDir(Context c) {
          File dir = c.getExternalCacheDir();
  
          if (dir == null)
              dir = c.getCacheDir();
  
          return dir;
      }
  </code></pre>
  
  <p>The idea is to use <code>getExternalCacheDir()</code> as first option because I assume that there will be more space available then <code>getCacheDir()</code>. Also the official docs states that the free space in <code>getCacheDir()</code> shouldn't be too large (1 MB?)</p>
  
  <blockquote>
    <p>you should always have a reasonable maximum, such as 1 MB, for the
    amount of space you consume with cache files, and prune those files
    when exceeding that space.</p>
  </blockquote>
  
  <p>My maximum space would be about 40 MB.</p>
  
  <p>So I have two questions:</p>
  
  <ol>
  <li><p>should I use <code>getExternalCacheDir()</code>? My apps minSDK = 14. Or should
  I use <code>getCacheDir()</code>?</p></li>
  <li><p>If I should use <code>getExternalCacheDir()</code> which permissions are required? According to the official documentation:</p></li>
  </ol>
  
  <blockquote>
    <p>Starting in KITKAT, no permissions are required to read or write to
    the returned path; it's always accessible to the calling app. This
    only applies to paths generated for package name of the calling
    application. To access paths belonging to other packages,
    WRITE_EXTERNAL_STORAGE and/or READ_EXTERNAL_STORAGE are required.</p>
  </blockquote>
  
  <p>So from my understanding WRITE_EXTERNAL_STORAGE (includes permission to read, at least prior API 19) is required to work properly with <code>getExternalCacheDir()</code> prior to KitKat (API 19).</p>
  
  <p>So the permission I have to set is: </p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="19"/&gt;
  </code></pre>
  
  <p>right?
  However I see some related bugs on Lollipop like this:
  <a href="https://stackoverflow.com/questions/27016647/why-do-i-need-the-write-external-storage-permission-with-getexternalcachedir-o">Why do I need the WRITE_EXTERNAL_STORAGE permission with getExternalCacheDir() on Android Lollipop?</a></p>
  
  <p>Should I add a <code>try-catch</code> block around <code>getExternalCacheDir()</code> and use <code>getCacheDir()</code> as fallback? </p>