How to display custom text, html and local store images on Andoid Webview
public void viewData()
{
WebView w=(WebView)findViewById(R.id.webView1);
w.getSettings().setAllowFileAccess(true);
myData= "<html><body><img src='file:///android-res/raw/myfile.jpg' />This is test webpage</body></html>";
w.loadDataWithBaseUrl("",mydata,"text\html","UTF-8","");
}
In this, i have putted a file "myfile.jpg" in res/raw/ folder.
And putted a webView with name "webView1"
Note:
Assests Folder Path:-> file:///android-assests/
Raw Folder Path:-> file:///android-res/raw/
{
WebView w=(WebView)findViewById(R.id.webView1);
w.getSettings().setAllowFileAccess(true);
myData= "<html><body><img src='file:///android-res/raw/myfile.jpg' />This is test webpage</body></html>";
w.loadDataWithBaseUrl("",mydata,"text\html","UTF-8","");
}
In this, i have putted a file "myfile.jpg" in res/raw/ folder.
And putted a webView with name "webView1"
Note:
Assests Folder Path:-> file:///android-assests/
Raw Folder Path:-> file:///android-res/raw/
No comments:
Post a Comment