Android 4.0.1 Breaks WebView HTML5 Local Storage



To solve this problem, follow the below-given steps −

For android versions less than 4.4, loading data into a webview with a file scheme as a directory like this won’t work.

browser.loadDataWithBaseUrl("file:///android_asset/", html, "text/html", "UTF-8", null);

Add a filename and it works on older Android versions −

browser.loadDataWithBaseUrl("file:///android_asset/new.html", htmlContent, "text/html", "UTF-8", null);

You can use the following too, in case your URL is http://www.demo.com −

browser.loadDataWithBaseURL("http://www.demo.com", htmlContent, "text/html", "utf-8", null);
Updated on: 2020-06-25T07:09:42+05:30

250 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements