public static boolean compareVersion(String serverVersion, String localVersion, Context context) {
    boolean versionIsNew = false;

    if (serverVersion.isEmpty() || localVersion.isEmpty()) {
      return false;
    }

    final SimpleDateFormat format = OTAConfig.getInstance(context).getFormat();
    if (format == null) {
      try {
        int serverNumber = Integer.parseInt(serverVersion.replaceAll("[\\D]", ""));
        int currentNumber = Integer.parseInt(localVersion.replaceAll("[\\D]", ""));
        versionIsNew = serverNumber > currentNumber;
      } catch (NumberFormatException e) {
        OTAUtils.logError(e);
      }
    } else {
      try {
        Date serverDate = format.parse(serverVersion);
        Date currentDate = format.parse(localVersion);
        versionIsNew = serverDate.after(currentDate);
      } catch (ParseException e) {
        OTAUtils.logError(e);
      }
    }

    return versionIsNew;
  }
 public static String getFullLocalVersion(Context context) {
   String source = OTAConfig.getInstance(context).getVersionSource();
   String sourceString = "";
   if (source.equalsIgnoreCase(UNAME_R)) {
     sourceString = OTAUtils.runCommand(UNAME_R);
   } else {
     sourceString = OTAUtils.getBuildProp(source);
   }
   return sourceString;
 }
  public static String extractVersionFrom(String str, Context context) {
    String version = "";

    if (!str.isEmpty()) {
      String delimiter = OTAConfig.getInstance(context).getDelimiter();
      int position = OTAConfig.getInstance(context).getPosition();

      if (delimiter.isEmpty()) {
        version = str;
      } else {
        if (delimiter.equals(".")) {
          delimiter = Pattern.quote(".");
        }
        String[] tokens = str.split(delimiter);
        if (position > -1 && position < tokens.length) {
          version = tokens[position];
        }
      }
    }

    return version;
  }