title: how to save recorded file with custome file name in android
body: <pre><code>when user click on stop recording button open popup and ask for file name enter file name then save to sdcard.right now i don't how to do it below my code..please guys help
  </code></pre>
  
  <p>in this code define 4 buttons and xml file when user click on start button start recording when user click on stop button stop record then similar for play and stop play button
  but question is how to save particular audio file with specific name </p>
  
  <pre><code>Audio.java
  public class HomeAdminfgt extends Fragment {
      private MediaRecorder myRecorder;
      private MediaPlayer myPlayer;
      private String outputFile = null;
      private Button startBtn;
      private Button stopBtn;
      private Button playBtn;
      private Button stopPlayBtn, Showaudio;
      private TextView text;
      private ImageView mic_image;
      private long startTime = 0L;
      private Handler customHandler = new Handler();
      long timeInMilliseconds = 0L;
      long timeSwapBuff = 0L;
      long updatedTime = 0L;
      TextView timervalue;
      File file;
      private String[] FilePathStrings;
      private String[] FileNameStrings;
      private File[] listFile;
      ProgressDialog progressDialog;
      public static String AudioUrl = "http://1biz.in/voice-call/voice.php?method=voiceCall";
      public static String voice_extra = "voice-call";
      public static String voice_string = "recording";
  
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
          // Inflate the layout for this fragment
          View view = inflater.inflate(R.layout.fragment_home_adminfgt, container, false);
          Showaudio = (Button) view.findViewById(R.id.showaudio);
  //        Showaudio.setOnClickListener();
          if (!Environment.getExternalStorageState().equals(
                  Environment.MEDIA_MOUNTED)) {
  
              Toast.makeText(getActivity(), "Error! No SDCARD Found!", Toast.LENGTH_LONG).show();
          } else {
              // Locate the image folder in your SD Card
              file = new File(Environment.getExternalStorageDirectory()
                      + File.separator + "Amuwa");
              // Create a new folder if no folder named SDImageTutorial exist
              file.mkdirs();
          }
  
          //File file = new File(dir, "recordvoice");
          text = (TextView) view.findViewById(R.id.text1);
          mic_image = (ImageView) view.findViewById(R.id.micImage);
        //  timervalue = (TextView) view.findViewById(R.id.timerValue);
          java.util.Date date = new java.util.Date();
          String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss")
                  .format(date.getTime());
          outputFile = Environment.getExternalStorageDirectory().
                  getAbsolutePath() + "/Amuwa/" + "AUD_" + timeStamp + ".wav";
  
          myRecorder = new MediaRecorder();
          myRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
          myRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
          myRecorder.setAudioEncoder(MediaRecorder.OutputFormat.AMR_NB);
          myRecorder.setOutputFile(outputFile);
          startBtn = (Button) view.findViewById(R.id.start);
          startBtn.setOnClickListener(new View.OnClickListener() {
  
              @Override
              public void onClick(View v) {
                  // TODO Auto-generated method stub
                  start(v);
              }
          });
  
          stopBtn = (Button) view.findViewById(R.id.stop);
          stopBtn.setOnClickListener(new View.OnClickListener() {
  
              @Override
              public void onClick(View v)
              {
                  // TODO Auto-generated method stub
                  stop(v);
              }
          });
  
          playBtn = (Button) view.findViewById(R.id.play);
          playBtn.setOnClickListener(new View.OnClickListener() {
  
              @Override
              public void onClick(View v)
              {
                  // TODO Auto-generated method stub
                  play(v);
              }
          });
  
          stopPlayBtn = (Button) view.findViewById(R.id.stopPlay);
          stopPlayBtn.setOnClickListener(new View.OnClickListener()
          {
  
              @Override
              public void onClick(View v)
              {
                  // TODO Auto-generated method stub
                  stopPlay(v);
              }
          });
          return view;
      }
  
  
  
  
  
      public void start(View view)
      {
          try
          {
              myRecorder.prepare();
              myRecorder.start();
           //   startTime = SystemClock.uptimeMillis();
             // customHandler.postDelayed(updateTimerThread, 0);
              Animation animation = new AlphaAnimation(1, 0); // Change alpha
              animation.setDuration(500); // duration - half a second
              animation.setRepeatCount(Animation.INFINITE); // Repeat animation
              animation.setRepeatMode(Animation.REVERSE); // Reverse animation at
  
              mic_image.startAnimation(animation);
          } catch (IllegalStateException e)
          {
              // start:it is called before prepare()
              // prepare: it is called after start() or before setOutputFormat()
              e.printStackTrace();
          } catch (IOException e) {
              // prepare() fails
              e.printStackTrace();
          }
  
          text.setText("Recording Point: Recording");
          startBtn.setEnabled(false);
          stopBtn.setEnabled(true);
  
          Toast.makeText(getActivity(), "Start recording...",
                  Toast.LENGTH_SHORT).show();
      }
  
      public void stop(View view)
      {
          try
          {
  
              myRecorder.stop();
              myRecorder.reset();
              myRecorder.release();
              stopBtn.setEnabled(false);
              playBtn.setEnabled(true);
              myRecorder  = null;
  
              mic_image.clearAnimation();
              text.setText("Recording Point: Stop recording");
  
              Toast.makeText(getActivity(), "Stop recording...",
                      Toast.LENGTH_SHORT).show();
          } catch (IllegalStateException e)
          {
              //  it is called before start()
              e.printStackTrace();
          } catch (RuntimeException e) {
              // no valid audio/video data has been received
              e.printStackTrace();
          }
      }
  
      public void play(View view)
      {
          try{
              myPlayer = new MediaPlayer();
              myPlayer.setDataSource(outputFile);
              myPlayer.prepare();
              myPlayer.start();
  
              playBtn.setEnabled(false);
              stopPlayBtn.setEnabled(true);
              text.setText("Recording Point: Playing");
              Toast.makeText(getActivity(), "Start play the recording...",
                      Toast.LENGTH_SHORT).show();
          }
          catch (Exception e)
          {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
      }
  
      public void stopPlay(View view)
      {
  
          try
          {
              if (myPlayer != null)
              {
  
                  myPlayer.stop();
                  myPlayer.release();
                  myPlayer = null;
                  playBtn.setEnabled(true);
                  stopPlayBtn.setEnabled(false);
                  text.setText("Recording Point: Stop playing");
  
                  Toast.makeText(getActivity(), "Stop playing the recording...",
                          Toast.LENGTH_SHORT).show();
              }
          } catch (Exception e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
      }
  </code></pre>