Created
July 20, 2017 10:55
-
-
Save rmkrishna/2a76db5ae5d98dcf588e92e657d4fe4d to your computer and use it in GitHub Desktop.
Clear cache from CookieManager android
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class WebUtil { | |
public static void clearCookies(Context context) { | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { | |
CookieManager.getInstance().removeAllCookies(null); | |
CookieManager.getInstance().flush(); | |
} else { | |
CookieSyncManager cookieSyncMngr = CookieSyncManager.createInstance(context); | |
cookieSyncMngr.startSync(); | |
CookieManager cookieManager = CookieManager.getInstance(); | |
cookieManager.removeAllCookie(); | |
cookieManager.removeSessionCookie(); | |
cookieSyncMngr.stopSync(); | |
cookieSyncMngr.sync(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment