I have an asset that I am trying to load in WebView. If the same file
is read from the SD card, all works fine, but I cannot read it when
packaged as an asset.

Here is the code


WebView webview = new WebView(this);

((ViewGroup)findViewById(R.id.content)).addView(webview, 0);
webview.getSettings().setJavaScriptEnabled(true);
webview.setWebViewClient(new WebViewClient()
{
    ... //code elided for brevity
    webview.loadUrl("file:///android_asset/Shopping/index.html");
}

This same code works fine if I use another html file if it isn't in
its own directory.

For example, this works:
webview.loadUrl("file:///android_asset/sample.html");

Also, as stated above, if I read it from an SD card this all is OK.

For example, this also works:
      webview.loadUtl("content://com.android.htmlfileprovider/sdcard/
downloads/Shopping/index.html");


The only think that doesn't work is when the thing is in its own
directory it seems. Is packaging an asset inside its own directory a
no no? I'd like to keep things tidy if possible, but if it cannot be
done then I will remove the Shopping directory and plunk everything
down under assets.

Thanks!

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to