androidandroid-studioandroid-cookiemanager

Where to find / browse cookies in app data folder?


I have my app ("myapp") with following example package signature: com.example.mycorp.myapp

I browsed via adb shell the app folder /data/data/com.example.mycorp.myapp/ to find any cookies - in vain.

Since I have WebView objects showing external links (html) and Google Login as an example, there should be some cookies created (at least iOS colleagues have there cookies on the same app for iOS).

So where are can I find any cookies regarding my own app?


Solution

  • Programmatically by means of CookieManager:

    Memeber variable

    private CookieManager cookieManager = null;
    

    In a onCreate() or another constructor

    cookieManager = new CookieManager();
    cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
    CookieHandler.setDefault(cookieManager);
    

    A checkCookies() Method which can be triggered frequently

    List<HttpCokie> cookies = cookieManager.getCookieStore().getCookies();
    

    Now, iterate through cookies and print them out.