public static boolean isWritable(final File file,final boolean makeDirs){
  if (file == null) {
    Log.e(FileUtils.class,"isWritable(): Null or Empty parameter given");
    return false;
  }
  final String fileParentDir=file.getParent();
  if (!TextUtils.isEmpty(fileParentDir)) {
    final File fileDir=new File(fileParentDir);
    if (!fileDir.exists()) {
      if (makeDirs)       return makeDirsForFile(file);
 else       return false;
    }
  }
  boolean isWritable=true;
  if (file.exists())   isWritable=file.canWrite();
 else {
    try {
      isWritable=file.createNewFile();
    }
 catch (    IOException e) {
    }
    if (isWritable)     isWritable=file.delete();
  }
  return isWritable;
}

public static boolean isWritable ( final File file , final boolean makeDirs ) { if ( file == null ) { Log . e ( FileUtils . class , "isWritable(): Null or Empty parameter given" ) ; return false ; } final String fileParentDir = file . getParent ( ) ; if ( ! TextUtils . isEmpty ( fileParentDir ) ) { final File fileDir = new File ( fileParentDir ) ; if ( ! fileDir . exists ( ) ) { if ( makeDirs ) return makeDirsForFile ( file ) ; else return false ; } } boolean isWritable = true ; if ( file . exists ( ) ) isWritable = file . canWrite ( ) ; else { try { isWritable = file . createNewFile ( ) ; } catch ( IOException e ) { } if ( isWritable ) isWritable = file . delete ( ) ; } return isWritable ; }
method checks if file could be written / deleted or created . method will create path / mkdirs if makedirs set to true and file ' s path doesn ' t exists .
