androidgoogle-chromeandroid-browser

Android programmatically delete Chrome / default browser cookies, history, searches


Like the title. I want to delete cookie, cache of browser of Android by coding in my application. (browser not webview) Thank you!


Solution

  • In your Activity or Service, add

    ContentResolver cR = getContentResolver();
    
    if(Browser.canClearHistory(cR)){
        Browser.clearHistory(cR);
        Browser.clearSearches(cR);
    }
    

    where Browser is the android.provider.Browser class.

    This will clear the default browser's history.