I have downloaded 2 files (1 HTML file and 1 image) from server in Environment.DIRECTORY_DOWNLOADS
. Now i am trying to load the HTML file (with image) saved in Environment.DIRECTORY_DOWNLOADS
in webview. But nothing is loaded.
What's the problem?
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
webView = (WebView) findViewById(R.id.webView);
button = (Button) findViewById(R.id.button);
File file = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
File htmlFile = new File(file.getAbsolutePath()+"/test.html");
webView.loadUrl(htmlFile.getAbsolutePath());
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
myDownload("http://xxxxxx.com/xxxx/test.html");
myDownload("http://xxxxxx.com/xxxx/mypic1.jpg");
} catch (Exception e) {
Toast.makeText(MainActivity.this, e.getMessage() + "\n" + e.getCause(), Toast.LENGTH_LONG).show();
}
//
}
});
}