title: How to Record Voice in android?
body: <p>I am trying to record the voice in android But it will create the .mp3 file on the path (sdcard/filename) But when i run this file it doesen't play because it doesn't record the voice.</p>
  
  <p>Here is My code</p>
  
  <pre><code>public void onClick(View v) {
          // TODO Auto-generated method stub
          switch(v.getId()){
          case(R.id.Button01):
              try {
                  //audio.start();
                  startRecord();
              } catch (IOException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
          case(R.id.Button02):
              //audio.stop();
              stopRecord();
          }
  
      }
       private void startRecord() throws IllegalStateException, IOException{
             // recorder = new MediaRecorder(); 
              recorder.setAudioSource(MediaRecorder.AudioSource.MIC);  //ok so I say audio source is the microphone, is it windows/linux microphone on the emulator? 
              recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); 
              recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); 
              recorder.setOutputFile("/sdcard/Music/"+System.currentTimeMillis()+".amr"); 
              recorder.prepare(); 
              recorder.start();      
          }
  
          private void stopRecord(){
              recorder.stop();
            //recorder.release();
          }
  
  
  
  }
  </code></pre>
  
  <p>Manifest file</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.RECORD_AUDIO" /&gt;
  &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
  </code></pre>