Is there any way to load and open files such as doc,docx,xls,pdf,etc. from sdcard to webview?
Asked
Active
Viewed 2,191 times
2 Answers
0
WebView can not open these files. You need to open them in a corresponding app like Microsoft Word, Excel, ... and Google PDF Viewer.

xdevs23
- 3,824
- 3
- 20
- 33
0
You can not open files in webview directly from sdcard, but alternet solution is you can upload them in google drive first and can open it in webview. like below.
WebView webview = (WebView) findViewById(R.id.webview);
webview.getSettings().setJavaScriptEnabled(true);
String pdf = "http://www.adobe.com/devnet/acrobat/pdfs/pdf_open_parameters.pdf";
webview.loadUrl("http://drive.google.com/viewerng/viewer?embedded=true&url=" + pdf);

Mehul Santoki
- 1,208
- 1
- 12
- 25
-
thanks mehul....it is also showing "no preview available" and i am also looking for other types file such as doc, xls, etc. – shripal Mar 29 '16 at 08:18
-
-
-
try to open this url : http://drive.google.com/viewerng/viewer?embedded=true&url=http://www.adobe.com/devnet/acrobat/pdfs/pdf_open_parameters.pdf – Mehul Santoki Mar 29 '16 at 08:29
-
yes Mehul..that url is working fine But, I am trying to load pdf file from sdcard..that is why i am not able to open. – shripal Mar 29 '16 at 08:44