I have tried each and every solution on SO about writing to external storage. working on it from 2 days but unable to write in Android Kitkat 4.2.2. I am clueless whats happening. My manifest files have Read & Write permissions and code for writing file is :
// make a new file directory inside the "sdcard" folder
    File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(
            Environment.DIRECTORY_PICTURES), "imgcaptureapp");
    // if the directory does not exist
    if (!mediaStorageDir.exists()) {
        // if you cannot make this directory return
        if (!mediaStorageDir.mkdirs()) {
            return null;
        }
    }
    // take the current timeStamp
    String timeStamp = new SimpleDateFormat("dd-MM-yyyy_HH:mm:ss").format(new Date());
    File mediaFile;
    // and make a media file:
    mediaFile = new File(mediaStorageDir.getPath() + File.separator + "IMG_" + timeStamp + ".jpg");
    return mediaFile;
My mediaFile.canwrite(); returning false.