I was trying to display a static html page in an android app having some images in it. I saved the image in assests folder and also in res/raw folder. I was loading html file with this technique and html file is also in res/raw folder.
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
String data = ResourceUtils.loadResToString(R.raw.temp, this);
final String mimetype = "text/html";
final String encoding = "UTF-8";
mWebView.loadData(data, mimetype, encoding);
I tried different ways to refer to image like.
img1.png, /img1.png, file:///img1.png, content://img1.png
HtmlViewer/assets/img1.png, content:///HtmlViewer/assets/img1.png and file:///HtmlViewer/assets/img1.png
PackageName/assets/img1.png, content:///PackageName/assets/img1.png and file:///PackageName/assets/img1.png
Can anyone tell me how to get path for image?