This code works for me but it is reported in fabric crashlytics not work on some devices and actually mkdirs retrun false I checked already the dir.exists() before .
File dir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + "/Gahvare/");
if (!dir.exists()) {
if (!dir.mkdirs()) {
Crashlytics.logException(new Exception("in downloadFileWithProgressBar directory not exist, path: " + dir.getPath() + " absolut path is :" + dir.getAbsolutePath()));
// callback.onFailure(CONNECTION_ERROR);
}
}