mytechead

Android & Wordpress Help center

Archive for the month “March, 2014”

Android: Enable local cookies in Phonegap webview

Have been creating Phonegap and Android hybrid app with mixed native and Phonegap specific UI components lately. Yesterday I came across a scenario where I was not able to get the cookie information. After hours of exploration found that a single missing line of code was all I needed to correctly retrieve my saved cookies. So here it goes:-

Inside your Activity which should extend CordovaActivity you should write:-

CookieManager.setAcceptFileSchemeCookies(true);

Just above the line:-

super.loadUrl(URL_TO_LOAD);

that is just before loading the webpage.

This will allow cookies to be accepted for file scheme URLs.

Hope it saves your time!

Post Navigation