Mark D
Mark D

Reputation: 1329

Web Page Not Available - Loading local HTML on Android

Yo guys, this is bugging me and I can't find a fix for it,

I have a simple activity to launch a WebView and display a HTML file

public class HelpViewer extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.help_page_layout);

    WebView browser = (WebView) findViewById(R.id.help_page_webview);
    browser.loadUrl("file:///android_asset/help.html/");
}}

The help_page_layout is your standard WebView resting in a LinearLayout - Not problems there.

The help.html is sitting under the /res/raw/ directory. From what I have see online, there shouldn't be a problem here either.

But when the WebView goes to load, it just tells me that the WebPage was not available because help.html couldn't be found.

What am I doing wrong?

Upvotes: 1

Views: 2153

Answers (1)

dave.c
dave.c

Reputation: 10908

This question suggests the file should be in /assets rather than /res/raw. You also have a trailing slash on the end of your URL.

Upvotes: 2

Related Questions