code: public static int parseInt(String val, int defValue){
          if(TextUtils.isEmpty(val)) return defValue;
          try{
              return Integer.parseInt(val);
          }catch (NumberFormatException e){
              return defValue;
          }
      }
docs: Parse a int from a String in a safe manner.
  
  @param val           the string to parse
  @param defValue      the default value to return if parsing fails
  @return              the parsed int, or default value