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.html
But, when the WebView
loads it, I don't see anything.
Who can help me?
WebView
code (assuming path is the path I've written above):
WebView webView = (WebView)findViewById(R.id.webView1);
File htmlFile = new File(path);
if(htmlFile.exists())
{
webView.loadUrl(htmlFile.getAbsolutePath());
}
Try this, adding in a file:///
and doing it a little differently:
WebView webView = (WebView)findViewById(R.id.webView1);
webview.loadUrl("file:///data/data/com.example.example/files/file.html");
Instead of this, however, you could just put the file into your assets
folder in the source code, and then do this:
WebView webView = (WebView)findViewById(R.id.webView1);
webview.loadUrl("file:///android_asset/file.html");