[英]Read pdf in Android Studio
I would read a file pdf in my project. 我会在项目中阅读pdf文件。 1 step: Where do I input PDF File? 步骤1:在哪里输入PDF文件? in which folder? 在哪个文件夹中? 2 step: How do I read it? 第2步:如何阅读? I just need to open it. 我只需要打开它。
I found this code but give me an error: The directory of the file si wrong 我找到了此代码,但给我一个错误:文件si的目录错误
protected void openPdf()
{
Intent intent = new Intent(Intent.ACTION_VIEW);
String path = Environment.getExternalStorageDirectory().getAbsolutePath()+" /PDF";
File file = new File(path, "law.pdf");
intent.setDataAndType(Uri.fromFile(file), "application/pdf");
startActivity(intent);
}
Replace the line 更换线
String path = Environment.getExternalStorageDirectory().getAbsolutePath()+" /PDF"; 字符串路径= Environment.getExternalStorageDirectory()。getAbsolutePath()+“ / PDF”;
to String path = Environment.getExternalStorageDirectory().getAbsolutePath()+"/";
到String path = Environment.getExternalStorageDirectory().getAbsolutePath()+"/";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.