public static boolean makeDirsForFile(final File file){
  if (file == null)   return false;
  Log.d("FileUtils","file: " + file + " isDirectory(): "+ file.isDirectory());
  final String fileParentDir=file.getParent();
  final File fileDir=TextUtils.isEmpty(fileParentDir) ? null : new File(file.getParent());
  boolean isSucceed=fileDir == null || fileDir.exists();
  if (isSucceed)   Log.d("FileUtils","fileDir: " + fileDir + " already exists(): "+ isSucceed);
  if (!isSucceed && fileDir != null) {
    isSucceed=fileDir.mkdirs();
    Log.d("FileUtils","fileDir: " + fileDir + " mkdirs(): "+ isSucceed);
  }
  return isSucceed;
}

public static boolean makeDirsForFile ( final File file ) { if ( file == null ) return false ; Log . d ( "FileUtils" , "file: " + file + " isDirectory(): " + file . isDirectory ( ) ) ; final String fileParentDir = file . getParent ( ) ; final File fileDir = TextUtils . isEmpty ( fileParentDir ) ? null : new File ( file . getParent ( ) ) ; boolean isSucceed = fileDir == null || fileDir . exists ( ) ; if ( isSucceed ) Log . d ( "FileUtils" , "fileDir: " + fileDir + " already exists(): " + isSucceed ) ; if ( ! isSucceed && fileDir != null ) { isSucceed = fileDir . mkdirs ( ) ; Log . d ( "FileUtils" , "fileDir: " + fileDir + " mkdirs(): " + isSucceed ) ; } return isSucceed ; }
method creates the file ' s path dirs and returns true if succeed . the difference from file . mkdirs ( ) is that mkdirs ( ) returns false in both cases : it can ' t create path or path already exists . this method will return false if path could not be created only .
