title: Android Dev: Accessing external SD card directly on Samsung devices (with extSdCard path)?
body: <p>I'm learning Android development so am relatively new to some of the technical Android concepts, but I do have a strong developer background. </p>
  
  <p>I am writing an app that I want to be able to directly access files on the user's SD card. The test device is a Samsung Galaxy Tab 4. </p>
  
  <p>Samsung appears to use a custom method of mounting the SD card, placing it at <code>/storage/extSdCard</code> rather than the more traditional <code>/sdcard</code>. </p>
  
  <p>In my app, I used the method <code>Environment.getExternalStoragePublicDirectory</code> method to request the path for storage, and was given a path which points to the internal storage rather than the SD card. (<code>/storage/sdcard0/...</code>)</p>
  
  <p>When I try to directly access the SD card storage (<code>/storage/extSdCard/...</code>), I get the error <code>open failed: EACCES (Permission denied)</code>.</p>
  
  <p>This device - and potentially any user's device - has very limited storage available on the internal memory. (This device has only 8GB of storage internally, most of which is taken up by apps.) Additionally, I want a potential app user to be able to put files onto their MicroSD card directly and not have to use an Android file transfer tool to load content into the app...</p>
  
  <p>Any way I can access the external SD card directly from an app running on a Samsung device?</p>
  
  <p>Test code:</p>
  
  <pre><code>public void doTest()
  {
      FileWriter fw;
  
      File f = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS), "test.txt");
      Log.i("file","Trying to write a file at: "+f.getPath());
      try {
          fw = new FileWriter(f);
          fw.write("You got a file.");
          fw.flush();
          fw.close();
          Log.i("file", "Successfully wrote the file.");
      }
      catch (IOException e)
      {
          Log.i("file_error", "Could not write the file.");
          Log.i("file_error",e.getMessage());
      }
  
      f = new File("/storage/extSdCard/Documents", "test.txt");
      Log.i("file","Trying to write a file at: "+f.getPath());
      try {
          fw = new FileWriter(f);
          fw.write("You got a file.");
          fw.flush();
          fw.close();
          Log.i("file", "Successfully wrote the file.");
      }
      catch (IOException e)
      {
          Log.i("file_error", "Could not write the file.");
          Log.i("file_error",e.getMessage());
      }
  }
  </code></pre>