how to change audio format on android application
<p>Actually i am working in audio recording,i want to choose my audio file as what i need,i created popupbox for showing format option,but i cant choose the selective one,in my case it will takes the default or first format.
can anyone please help me?</p>

<pre><code>public String getFilename(){
    String filepath = Environment.getExternalStorageDirectory().getPath();
    File file = new File(filepath,AUDIO_RECORDER_FOLDER);

    if(!file.exists()){
        file.mkdirs();
    }
    gfilename = (file.getAbsolutePath() + "/" + System.currentTimeMillis() + file_exts[currentFormat]);
    return (gfilename );
}

@SuppressLint("NewApi")
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)
    {
        mDbHelper.updateTestFileName(mRowId, gfilename); 
        recorder.stop();
        recorder.reset();
        recorder.release();             
        recorder = null;
        }
    displayFormatDialog();

}

private void displayFormatDialog(){
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    String formats[] = {"MPEG 4", "3GPP", "AMR", "Mp3"};

    builder.setTitle(getString(R.string.choose_format_title))
           .setSingleChoiceItems(formats, currentFormat, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                currentFormat = which;
                //setStopButtonCaption();

                dialog.dismiss();
            }
           })
           .show();
}
</code></pre>
