Loading local html file in webView android

后端 未结 3 2046
独厮守ぢ
独厮守ぢ 2020-12-24 02:01

I have to load an existing html file into a WebView that is located at this path in the file system:

/data/data/com.example.example/files/file.         


        
3条回答
  •  生来不讨喜
    2020-12-24 03:07

    You need to implement a ContentProvider to map local files to uris as explained in this link how to display a local file into Android Webview

    or you just load any html page from Assets folder like below:

     WebView wv= (WebView)findViewById(R.id.webView1);
     wv.loadUrl("file:///android_asset/yourfile.html");
     wv.getSettings().setJavaScriptEnabled(true);
    

提交回复
热议问题