title: How does storage access change on Android 6?
body: <h2>Background</h2>
  
  <p>Android had a lot of changes as to how to handle the SD-card and storage in general:</p>
  
  <ul>
  <li>API 3 - you get all access, no permission needed</li>
  <li>API 4-15 - you need to use WRITE_EXTERNAL_STORAGE, and you get all access.</li>
  <li>API 16-18 - if you wish only to read, use READ_EXTERNAL_STORAGE</li>
  <li>API 19-20 - you can't read or write to secondary external storage (SD-card), unless your app is a system app, or you have root.</li>
  <li>API 21-22 - in order to access the SD-card, you need to ask the user for permission, and use the DocumentFile API instead of the File API. This raied a lot of questions, as I've written about <a href="https://stackoverflow.com/q/26744842/878126"><strong>here</strong></a>, <a href="https://stackoverflow.com/q/31662055/878126"><strong>here</strong></a> and <a href="https://stackoverflow.com/q/32019734/878126"><strong>here</strong></a>.</li>
  </ul>
  
  <p>Starting with API 23 (Android 6), things seem to change yet again...</p>
  
  <h2>The problem</h2>
  
  <p>For API 23, there are at least 2 things that are new and are storage-related :</p>
  
  <ul>
  <li>"<a href="https://developer.android.com/preview/behavior-changes.html#behavior-adoptable-storage" rel="noreferrer"><strong>Adoptable Storage Devices</strong></a>" - The user can optionally make the SD-card as something that's like the primary external storage.</li>
  <li>As part of the <a href="https://developer.android.com/preview/features/runtime-permissions.html#coding" rel="noreferrer"><strong>new permissions mechanism</strong></a> (requesting permissions at runtime), it seems that storage is also a permission the user needs to confirm. This is for both READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE</li>
  </ul>
  
  <p>Since there is no Android 6 device out there that has SD-card, and because the emulator itself doesn't really have the ability to use an SD-card, it's still impossible to know what's going on.</p>
  
  <h2>The questions</h2>
  
  <ol>
  <li><p>Will the SD-card get the access using the File-API instead of DocumentFile?</p></li>
  <li><p>If I want access to all external storage paths (including SD-card), does this mean I need to request this permissions twice: one for the primary external storage and one for the SD-card?</p></li>
  <li><p>Are files on the SD-card accessible in any way before the manual granting of the permission?</p></li>
  <li><p>Suppose the user has chosen to use "Adoptable Storage Devices", what does it mean for the various functions that retrieve the paths of the app's files? For example : getFilesDir, getExternalFilesDir,... ? Would the oder of getExternalFilesDirs change because of it?</p></li>
  <li><p>What happens to the files of the app when the user moves the app from/to the SD-card (using the "Adoptable Storage Devices") ? What about the app's files on the SD-card? Would they stay? Or would they move somewhere?</p>
  
  <p>For example, if the app has "file1.txt" on the SD-card, on path "/storage/extSdCard/Android/data/appPackageName", and it has a file "file2.txt" (or even the same name) on the primary external storage on path "/storage/emulated/0/Android/data/appPackageName". After switching, what would happen for those files? How would they merge into a single folder, if at all?</p></li>
  <li><p>When moving the app to the SD-card (using "Adoptable Storage Devices"), does it mean no internal storage will be used?</p></li>
  </ol>