My Code:-
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.webview);
// defining the WebView
WebView myWebView = (WebView) findViewById(R.id.web);
// Websetting can be used to define several web related settings.
WebSettings webSettings = myWebView.getSettings();
// Enabling JAVASCRIPT
webSettings.setJavaScriptEnabled(true);
// providing navigational access
myWebView.setWebViewClient(new WebViewClient());
// loading the URL
myWebView.loadUrl("http://abcd.com");
}
Its the simplest webview anyone will find out there, and i want to do some modification there but am unable to, so plz help me with it.
The site i am opening contains a lot of images, now i want to know, when a website is accessed all the images and text it contains are download to show it on the UI and when we close the page all of it is lost,if i guessed it right.To download a image, one will have to specifically download it. Like we do in Opera Browser or any other one.
So i want to download all the image my webview opens in the UI into an dir (path known /sdcard/pics) on my SDCard automatically. Is there a way?
An alternative to using the cache directory approach is to intercept all requests to images on-the-fly, as the
WebViewloads them. You can set aWebViewClientto yourWebViewthat implements one of the following methods:The first method should work on all devices out there, but will probably result in downloading the resource twice: once manually to save it in a specific directory on the SD card, and once by the
WebViewitself. The second method allows you to return the downloaded resource after saving it somewhere, effectively resulting in just a single download.You should able to find plenty of examples here on SO or by querying your favourite search engine.