I am Developing a android application where I am showing a pdf file in web view. code is as follows
pDialog = new ProgressDialog(Units.this);
pDialog.setTitle("Please Wait");
pDialog.setMessage("Loading...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(false);
webview = (WebView) findViewById(R.id.webView1);
webview.getSettings().setJavaScriptEnabled(true);
webview.setWebViewClient(new WebViewClient() {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
pDialog.show();
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
pDialog.dismiss();
}
});
String pdf = "http://XX.xxx.xx.xxx/webservice/testbook.pdf";
webview.loadUrl("http://docs.google.com/gview?embedded=true&url=" + pdf);
}
It is working fine. But it download pdf each time when ever it is called. I want it should download only once in cache or temp memory(Not in External directory) and viewable in app until it is removed.
WebView is basically used for loading webpages in your app. For your question I think WebView is not an option. You can follow these steps
Next time when app loads, display if file exists, else download again.
Also check for PDFRenderer.