i know how to record voice as following code
String path = android.os.Environment.getExternalStorageDirectory()+"/Record/test.3gp";
boolean exists = (new File(android.os.Environment.getExternalStorageDirectory()+"/Record/")).exists();
if(!exists)
{
newFile(android.os.Environment.getExternalStorageDirectory()+"/Record/").mkdirs();
}
MediaRecorder recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setOutputFile(path);
try {
recorder.prepare();
recorder.start();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
In this code i give output path in “recorder.setOutputFile(path);” it’s work fine but my problem is if i record again it will overwrite the same path, so pls help me how to save mulitiple voice in same path in sdcard pls help me
The file is overwritten because the
MediaRecorderobject gets the same output path every time. You’ll need to provide distinct names for output file each time.A good way can be using the date/time of the day in the filename.
A trivial example can be: