Search code examples
androidwebviewandroidpdfviewer

how to get pdf from internal storage in android Using WebView or AnyConcept


how to get pdf from internal storage in android Using WebView or AnyConcept. i have to get pdf in an activity from internal storage.Can anyone of u guys let me know about this .Thank You.


Solution

  • String filename = null;
                    File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath() +"/"+ filename);
                    Intent target = new Intent(Intent.ACTION_VIEW);
                    target.setDataAndType(Uri.fromFile(file),"application/pdf");
                    target.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
    
                    Intent intent = Intent.createChooser(target, "Open File");
    startActivity(intent);

    and give pdf filename