/**
   * Creates a WebdavClient to access a URL and sets the desired parameters for ownCloud client
   * connections.
   *
   * @param uri URL to the ownCloud server
   * @param context Android context where the WebdavClient is being created.
   * @return A WebdavClient object ready to be used
   */
  public static WebdavClient createOwnCloudClient(
      Uri uri, Context context, boolean followRedirects) {
    try {
      registerAdvancedSslContext(true, context);
    } catch (GeneralSecurityException e) {
      Log_OC.e(
          TAG,
          "Advanced SSL Context could not be loaded. Default SSL management in the system will be used for HTTPS connections",
          e);

    } catch (IOException e) {
      Log_OC.e(
          TAG,
          "The local server truststore could not be read. Default SSL management in the system will be used for HTTPS connections",
          e);
    }

    WebdavClient client = new WebdavClient(getMultiThreadedConnManager());

    client.setDefaultTimeouts(DEFAULT_DATA_TIMEOUT, DEFAULT_CONNECTION_TIMEOUT);
    client.setBaseUri(uri);
    client.setFollowRedirects(followRedirects);

    return client;
  }