MediaRecorder, I can't write on SDcard
<p>I want to record voice in android, and I try to develop a small application for testing, so wen I run my application it told me that I can't write on the sdcard, so there is my code:</p>

<pre><code>public class MainActivity extends Activity {

 private static final String LOG_TAG_ENREGISTREUR = null;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        Button record_btn = (Button)findViewById(R.id.button1);
        Button stop_btn = (Button)findViewById(R.id.button2);
        File fileRecord = null;
        final MediaRecorder media = new MediaRecorder();
        String state = android.os.Environment.getExternalStorageState();
        if(!state.equals(android.os.Environment.MEDIA_MOUNTED)){

            Log.e(LOG_TAG_ENREGISTREUR,"SDcard not found!");
            return;
        }

        File repertoryStockage = Environment.getExternalStorageDirectory();
        if(!repertoryStockage.canWrite()){

            Log.e(LOG_TAG_ENREGISTREUR,"Impossible , you can't write");

            return;
        }

        try {

            fileRecord = File.createTempFile("RecordingAudio", ".mp4",repertoryStockage);
        } catch (Exception e) {
            Log.e(LOG_TAG_ENREGISTREUR,"Probleme E/S before recording");
            return;
        }
        media.setAudioSource(MediaRecorder.AudioSource.MIC);
        media.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
        media.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
        media.setOutputFile(fileRecord.getAbsolutePath());

        record_btn.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                try {
                    media.prepare();
                } catch (IllegalStateException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                media.start();

            }
        });

        stop_btn.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {



                media.stop();
                media.release();

            }
        });
    }



}
</code></pre>

<p>and i add permissions in Manifest:</p>

<pre><code>&lt;uses-permission android:name="android.permission.RECORD_AUDIO"/&gt;
&lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/&gt;
</code></pre>

<p>an other thing I create a SDcard and I add it to emulator by : -sdcard "[Path of sdcard]"
so what is the problem? </p>
