when im run it im getting this error like "File or folder not found" and " file dosnt exit or can't be opened "..
This is the code sir.. i want the how to view pdf files from assets or in raw folder sir.. its very imp for my project try to slove my problem sir.. and tell me clearly im new to android sir.. can any one send me code cloerly how to do it..
enter code here
Uri path = Uri.parse("android.resource:///com.example.pratice/raw/em");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(path, "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
try {
startActivity(intent);
}
catch (ActivityNotFoundException e){
Toast.makeText(this, "NO Viewer", Toast.LENGTH_SHORT).show();
}
Few, if any, Android PDF viewer apps will honor the android.resource
scheme, and there is no Uri
scheme for assets.
If you want to serve up a PDF file, copy it from assets or a raw resource into internal storage, then use FileProvider
to make it available to other apps. Here is a sample application that does this.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.