MW_hk
MW_hk

Reputation: 1191

Android reading html file from external storage

I am trying to show the html files in /storage/sdcard0/...

WebView engine = (WebView) (findViewById(R.id.webView1));
engine.setWebViewClient(new WebViewClient());
engine.loadUrl(Environment.getExternalStorageDirectory().getPath() + "testing.html");

but the webpage failed to display.... Can anybody help? Thanks!

Upvotes: 1

Views: 2789

Answers (2)

No_Rulz
No_Rulz

Reputation: 2719

Use

engine.loadUrl("file:///"+Environment.getExternalStorageDirectory().getAbsolutePath() + "testing.html");

Upvotes: 2

MW_hk
MW_hk

Reputation: 1191

SOLVED!!! should add "file:///" in the front =]=]

engine.loadUrl("file:///" + 
Environment.getExternalStorageDirectory().getPath() + 
"testing.html");

Upvotes: 7

Related Questions