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

前端 未结 2 1436
灰色年华
灰色年华 2021-01-06 14:27

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

2条回答
  •  被撕碎了的回忆
    2021-01-06 15:29

    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.

提交回复
热议问题