title: MediaRecorder.prepare() throwing IOException
body: <p>I have an IOException caused by MediaRecorder.prepare(), and I have found no solution for it, even after searching in multiple places. I have used the code in the official Android Developers guide for this. My code is the following:</p>
  
  <pre><code>private void startRecording(String fileName) {
      mRecorder = new MediaRecorder();
      mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
      mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
      mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
      mRecorder.setOutputFile(fileName);
  
      try {
          mRecorder.prepare();
      } catch (IOException e) {
          Log.e("RecordApp", "prepare() failed " + fileName);
      }
  
      mRecorder.start();
  }
  </code></pre>
  
  <p>I know for a fact that the filename string is not null, as it is controlled by an EditText which I know is working properly for sure. </p>
  
  <p>Just to clarify what the string filename is. Since I plan to have this data on internal storage, I just have the plain name (say I want the file to be "test"), which in this case would be the string "test". I don't know if that would be an issue or not, however.</p>
  
  <p>Any help is appreciated. Thank you. </p>
  
  <p>EDIT 1: A new issue arising (look at the first comment at @Burrough 's post). </p>
  
  <pre><code>private void stopRecording(){
          if(recorder != null){
              recorder.stop();
          }
      }
  
  // stopRecording name of the button.
  stopRecording.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  thread.interrupt();
                  onorig=false;
                  thread = null;
                  startRecording.setEnabled(true);
                  stopRecording.setEnabled(false);
                  try {
                      Log.i("DOG", processCode(originalcode));
                      Log.i("DOG", processCode(code));
                      Log.i("DOG", Arrays.toString(checkNotes(originalcode, code)));
                  } catch(NullPointerException npe){}
                  code = "";
                  stopRecording();
                  Calendar calendar = Calendar.getInstance();
              }
          });
  </code></pre>
  
  <p>I am using TarsosDSP pitch recognition. </p>