How do I persist cookies when using HTTPUrlConnection?

后端 未结 4 876
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-01 03:33

I\'ve begun using the recommended HTTPUrlConnection and moved away from the DefaultHTTPClient. One of the things that I haven\'t been able to glue

4条回答
  •  星月不相逢
    2020-12-01 04:13

    Checkout the implementation in the link below. It saves the cookies by hostname like the original java.net.InMemoryCookieStore implementation does.

    Besides that it contains a SerializableHttpCookie to be able to serialize the complete HashMap into the SharedPreferences.

    https://gist.github.com/jacobtabak/78e226673d5a6a4c4367

提交回复
热议问题