在 CookieManager 中 setCookie 后是否需要刷新?

Ely*_*lye 5 android webkit android-webview cookiemanager android-cookiemanager

我有一段代码将 okHttp 中的 cookie 写入 CookieManager,如下所示。

@Override
public void saveFromResponse(HttpUrl url, List<Cookie> cookies) {
    CookieManager webviewCookieManager = CookieManager.getInstance();
    String urlString = url.toString();

    for (Cookie cookie : cookies) {
        webviewCookieManager.setCookie(urlString, cookie.toString());
    }
    webviewCookieManager.flush();
}
Run Code Online (Sandbox Code Playgroud)

我调用flush的 API 如下所示。

/**
 * Ensures all cookies currently accessible through the getCookie API are
 * written to persistent storage.
 * This call will block the caller until it is done and may perform I/O.
 */
public abstract void flush();
Run Code Online (Sandbox Code Playgroud)

但是,即使我删除它,setCookie它本身似乎仍然存在。我还需要吗flush