title: Getting path for physical SD card in Oreo (API26)
body: <p>I'm writing a Android app. If I identify a physical SD card (see later the code), I would offer to save the files data to the card (the data are 300MB-800MB). I would use the "app-specific directory", that the system deletes when the user uninstalls the app. If I cannot identify the SD using the code, simply I don't offer the possibility.</p>
  
  <p>I'm using Android Studio 3.0.1 (but same problem in 3.1) and AVD (SD in external file).</p>
  
  <p>Until API25 the following code identifies correctly the SD card:</p>
  
  <pre><code>String mySDPath = "";
  if( Build.VERSION.SDK_INT &gt;= 21 ) {
     File[] ExternalStorage = ContextCompat.getExternalFilesDirs( myContext, null );
     Emulated = true;
     for( int i = 0; i &lt; ExternalStorage.length; i++ ) {
        Emulated = Environment.isExternalStorageEmulated( ExternalStorage[i] );
        if( !Emulated ) {
           mySDPath = ExternalStorage[i].getAbsolutePath();
           break;
        }
     }
  }
  </code></pre>
  
  <p>Starting from AVD API26 the "physical SD" is not recognized.
  After the line:</p>
  
  <pre><code>File[] ExternalStorage = ContextCompat.getExternalFilesDirs( myContext, null );
  </code></pre>
  
  <p>I see in the debugger for API25:</p>
  
  <pre><code>ExternalStorage[0] = /storage/emulated/0/Android/data/my.app/files
  ExternalStorage[1] = /storage/10E7-191B/Android/data/my.app/files
  </code></pre>
  
  <p>but for API26 only:</p>
  
  <pre><code>ExternalStorage[0] = /storage/emulated/0/Android/data/my.app/files
  </code></pre>
  
  <p>Using Android Studio "Device File Explorer" I see:</p>
  
  <ul>
  <li><a href="https://i.stack.imgur.com/mBQHL.png" rel="nofollow noreferrer">API25</a></li>
  <li><a href="https://i.stack.imgur.com/kMRMh.png" rel="nofollow noreferrer">API26</a></li>
  </ul>
  
  <p>Any suggestions?</p>
  
  <p>Many thanks</p>