Reputation: 2354
I try call the default audio recorder with intent and send path to audio recorder than save voice in my path in sdcard.I use this code:
File audioFile = new File(Environment.getExternalStorageDirectory().getPath() + "/nabege" + File.separator + "audio"
+ File.separator + System.currentTimeMillis() + ".amr");
Uri audioUri = Uri.fromFile(audioFile);
record_audio_Intent.putExtra(MediaStore.EXTRA_OUTPUT, audioUri);
startActivityForResult(record_audio_Intent, 0);
This app save voice in default path. This path (nabege/audio) created in sdcard and exist.Please help
Upvotes: 0
Views: 1416
Reputation: 363
Sound recording via intent always saves the recorded file to root of sdcard (or to a default path). Also, this intent may not be supported in certain phone models.
You must use MediaRecorder directly if you want to save recorded files to your custom paths.
Like this:
MediaRecorder recorder = null;
private void startRecording(File file) {
if (recorder != null) {
recorder.release();
}
recorder = new MediaRecorder();
recorder.setAudioSource(AudioSource.MIC);
recorder.setOutputFormat(OutputFormat.THREE_GPP);
recorder.setAudioEncoder(AudioEncoder.AMR_WB);
recorder.setOutputFile(file.getAbsolutePath());
try {
recorder.prepare();
recorder.start();
} catch (IOException e) {
Log.e("giftlist", "io problems while preparing [" +
file.getAbsolutePath() + "]: " + e.getMessage());
}
}
Upvotes: 1