Android Development: Using Image From Assets In A WebView's HTML

AlexPriceAP picture AlexPriceAP · Sep 23, 2010 · Viewed 32.4k times · Source

In my app I'm making a basic HTML help document. I wanted my app's logo in the HTML img tag itself, but I don't know how I'd reference to the logo which will be stored in assets.

Is this possible, if so how?

Thanks for the help!

Answer

spatialist picture spatialist · Sep 1, 2011

Put your Logo into the assets directory eg: assets/logo.png

Then load your html with:

webView.loadDataWithBaseURL("file:///android_asset/", htmlData, "text/html", "utf-8", null);

Reference your img like:

<img src="logo.png">