public static boolean renameFile(File inputPath,File newFilePath){
  if (newFilePath.exists()) {
    Log.e(TAG,"File path already exists: " + newFilePath.getAbsolutePath());
    return false;
  }
  if (inputPath.isDirectory()) {
    Log.e(TAG,"Input path is directory: " + inputPath.getAbsolutePath());
    return false;
  }
  if (!createDirectoryIfNeeded(newFilePath.getAbsolutePath())) {
    Log.e(TAG,"Failed to create parent directory for file: " + newFilePath.getAbsolutePath());
    return false;
  }
  return inputPath.renameTo(newFilePath);
}

public static boolean renameFile ( File inputPath , File newFilePath ) { if ( newFilePath . exists ( ) ) { Log . e ( TAG , "File path already exists: " + newFilePath . getAbsolutePath ( ) ) ; return false ; } if ( inputPath . isDirectory ( ) ) { Log . e ( TAG , "Input path is directory: " + inputPath . getAbsolutePath ( ) ) ; return false ; } if ( ! createDirectoryIfNeeded ( newFilePath . getAbsolutePath ( ) ) ) { Log . e ( TAG , "Failed to create parent directory for file: " + newFilePath . getAbsolutePath ( ) ) ; return false ; } return inputPath . renameTo ( newFilePath ) ; }
renames a file . < p / > can only be used for regular files , not directories .
