• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Record audio sound in android studio

I am following this tutorial (
) to record and play sounds. but having the problem in saving sound to folder. everything is working fine but when i check the folder where i saved the file then it is empty.

String recordPath = getActivity().getExternalFilesDir("/").getAbsolutePath();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy_MM_dd_hh_mm_ss", Locale.CANADA);
Date now = new Date();
recordFile = "Recording_"+formatter.format(now)+".3gp";
filenameText.setText("Recording filename : "+recordFile);
Toast.makeText(getActivity().getApplicationContext(),recordPath+"/"+recordFile,Toast.LENGTH_LONG).show();

mediaRecorder = new MediaRecorder();
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mediaRecorder.setOutputFile(recordPath+"/"+recordFile);



kindly help me out of it or suggest any other way to record audio files.
 
Back
Top Bottom