title: Android I want to access my external storage folder
body: <p>How can I access my External storage folder?</p>
  
  <p>I am trying to fetch the files from external storage and that want to be display in my application. How  can i get an audio file from external storage and view it in my application?</p>
  
  <p>Here's my code:</p>
  
  <pre><code>private String getFilename()
  {
  
      String filepath = Environment.getExternalStorageDirectory().getPath();
  
      File file = new File(filepath, AUDIO_RECORDER_FOLDER);
  
      if (!file.exists()) {
          file.mkdirs();
      }
  
      return (file.getAbsolutePath() + "/" + System.currentTimeMillis() + file_exts[currentFormat]);
  }
  private void startRecording() {
      recorder = new MediaRecorder();
  
      recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
      recorder.setOutputFormat(output_formats[currentFormat]);
      recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
      recorder.setOutputFile(getFilename());
  
      //recorder.setOnErrorListener(errorListener);
      //recorder.setOnInfoListener(infoListener);
  
      try {
          recorder.prepare();
          recorder.start();
      } catch (IllegalStateException e) {
          e.printStackTrace();
      } catch (IOException e) {
          e.printStackTrace();
      }
  }
  
  private void stopRecording() {
      if (null != recorder) {
          recorder.stop();
          recorder.reset();
          recorder.release();
          recorder = null;
      }
  }
  
  
  
  private View.OnClickListener btnClick = new View.OnClickListener() {
      @Override
      public void onClick(View v) {
          switch (v.getId()) {
          case R.id.button1: {
              Toast.makeText(call1.this, "Start Recording",
                      Toast.LENGTH_SHORT).show();
  
              enableButtons(true);
              startRecording();
  
              break;
          }
          case R.id.button2: {
              Toast.makeText(call1.this, "Stop Recording", Toast.LENGTH_SHORT)
              .show();
              enableButtons(false);
              stopRecording();
  
              break;
          }
  
          case R.id.button3: { 
              Toast.makeText(call1.this, "Playing Audio", Toast.LENGTH_SHORT)
              .show();
  }
  </code></pre>