I am facing hard time to preview PDF document present in SD card/internal memory in Android as it does not have its own API. I tried following:
Intent showIntent = new Intent(Intent.ACTION_VIEW);
showIntent.setDataAndType(uri, "application/pdf");
showIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(showIntent);
But its not working.
I tried checking using Webview as well but still no result.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web_view);
String file = getIntent().getStringExtra("previewfile");
webView = (WebView) findViewById(R.id.webView1);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("http://docs.google.com/gview?embedded=true&url="+file);}
I have seen some libraries which can be used if the file is present in Asset folder but only problem is that I cant put file in asset folder programatically.
Is there any way of previewing the file stored in SD card? Please help.