i use the below code to create file in android but the files are not created when i use android version 4.x but when i use version like 2.x the code working fine and the files are created

  File path = new File( Environment.getExternalStorageDirectory()+"/FullDuplexCall/");
   path.mkdirs();
    try {
        sendfile = File.createTempFile("sendfile", ".txt",path);
        Log.d("VS", "create sender file");
        recfile=File.createTempFile("recfile",".txt",path);
        Log.d("VS", "create reciever file");
        dos = new DataOutputStream(
                new BufferedOutputStream(new FileOutputStream(sendfile)));
        dos1 = new DataOutputStream(
                new BufferedOutputStream(new FileOutputStream(recfile)));
    } catch (IOException e) {
        throw new RuntimeException("Couldn't create file on SD card", e);
    }

and here is the permission

 <uses-permission android:name="android.permission.RECORD_AUDIO"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.INTERNET"> </uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"> </uses-permission> 

As per Android documentation you should use getExternalStoragePublicDirectory which will get you access to top-level public directory of specific type. Bellow snippet is getting access to pictore directory

public File getAlbumStorageDir(String albumName) {
    // Get the directory for the user's public pictures directory.
    File file = new File(Environment.getExternalStoragePublicDirectory(
            Environment.DIRECTORY_PICTURES), albumName);
    if (!file.mkdirs()) {
        Log.e(LOG_TAG, "Directory not created");
    }
    return file;
}

If you still wish to stick with your call getExternalStorageDirectory() then you need to chck if storage is available as per documentation description

Return the primary external storage directory. This directory may not currently be accessible if it has been mounted by the user on their computer, has been removed from the device, or some other problem has happened. You can determine its current state with getExternalStorageState().