public String generateSaveFile(String filename,long filesize) throws GenerateSaveFileError {
  String path=generateTempSaveFileName(filename);
  File expPath=new File(path);
  if (!Helpers.isExternalMediaMounted()) {
    Log.d(Constants.TAG,"External media not mounted: " + path);
    throw new GenerateSaveFileError(STATUS_DEVICE_NOT_FOUND_ERROR,"external media is not yet mounted");
  }
  if (expPath.exists()) {
    Log.d(Constants.TAG,"File already exists: " + path);
    throw new GenerateSaveFileError(STATUS_FILE_ALREADY_EXISTS_ERROR,"requested destination file already exists");
  }
  if (Helpers.getAvailableBytes(Helpers.getFilesystemRoot(path)) < filesize) {
    throw new GenerateSaveFileError(STATUS_INSUFFICIENT_SPACE_ERROR,"insufficient space on external storage");
  }
  return path;
}

public String generateSaveFile ( String filename , long filesize ) throws GenerateSaveFileError { String path = generateTempSaveFileName ( filename ) ; File expPath = new File ( path ) ; if ( ! Helpers . isExternalMediaMounted ( ) ) { Log . d ( Constants . TAG , "External media not mounted: " + path ) ; throw new GenerateSaveFileError ( STATUS_DEVICE_NOT_FOUND_ERROR , "external media is not yet mounted" ) ; } if ( expPath . exists ( ) ) { Log . d ( Constants . TAG , "File already exists: " + path ) ; throw new GenerateSaveFileError ( STATUS_FILE_ALREADY_EXISTS_ERROR , "requested destination file already exists" ) ; } if ( Helpers . getAvailableBytes ( Helpers . getFilesystemRoot ( path ) ) < filesize ) { throw new GenerateSaveFileError ( STATUS_INSUFFICIENT_SPACE_ERROR , "insufficient space on external storage" ) ; } return path ; }
creates a filename ( where the file should be saved ) from info about a download .
