android - MediaRecorder.prepare() exception - No such file or directory -


I am trying to record the audio, when a debug appears on , a wild exception appears .prepare ()

This is my record () method.

  Private Zero Grabar (see V) {mediaRecorder = New MediaRecorder (); Date Today = Calendar. Gate Instance (). GetTime (); String nombrefichero = String.valueOf (today.getDate ()) + "+" + string.valuef (today .getMonth () + 1) + "-" + string.valuef (today.get (++) +1900 ) + "_" + String.valuef (today's guesthors ()) + "." + String.valueOf (Today GetMinutes ()) + "." + String.valueOf (today .getSeconds ()) + ".3gp"; MediaRecorder.setOutputFile (VarGlobales.Ruta + "/" + VarGlobales.Trabajo + "/ audio /" + nombrefichero); // VarGlobales.Ruta - & gt; Environment.getExternalStorageDirectory () getAbsolutePath () .; // VarGlobales.Trabajo - & gt; 001 Media Records Audiocoras (Media Records. AudioSOS.mic); MediaRecorder.setOutputFormat (MediaRecorder.OutputFormat.THREE_GPP); MediaRecorder.setAudioEncoder (MediaRecorder.AudioEncoder.AMR_NB); Try MediaRecorder.prepare (); MediaRecorder.start (); Toast. Make Text (Contaxo, "Grabando ...", Toast.LnGHIHART). Show (); } Grip (IOE EXPRESS E) {Toast. Make Text (Contaxo, "Follow Ann La Bataiyan", Toast. LNGHHRT). Show (); }}   

There are RECORD_AUDIO and WRITE_EXTERNAL_STORAGE permissions in AndroidManifest.xml.

The exception states:

  java.io.FileNotFoundException: /storage/sdcard0/001/Audio/25-7-2014_8.53.6.3gp: Open Failed: ENOENT (no such file or directory)    

The exception says that the file does not exist, am I just creating it?

What am I doing wrong?

Please read the documentation. It says that mediaRecorder.setOutputFile () after setOutputFormat () and Ready () .

// To create a directory in sdcard:

  string path = environment .getExternalStorageDirectory (). GetAbsolutePath () + "/ MyFolder /"; File directory = new file (path); If (! Dir.exists ()) dir.mkdirs (); String myfile = path + "filename" + ".mp4";   

Then specify it as your output file.

  setOutputFile (myfile);    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -