Search code examples
javaandroidandroid-internal-storage

Now able to load html page in web view when trying to load it from internal storage of device


I have created an index.html inside a directory, named as "TestingPurpose", of my internal storage of device.

I was trying to load the html page which is inside internal storage of device, but not able to load it

String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/TestingPurpose/index.html";
webView.loadUrl(path);

But working if I try to load from assets directory

String path = "file:///android_asset/index.html";
webView.loadUrl(path);

How I can make the URL load in web view from the file which is inside the internal storage of device?


Solution

  • Try this:

    String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/TestingPurpose/index.html";
    String url = "file://" + path;
    webView.loadUrl(url);