是什么在jblough / Android的-PDF查看器库的路径? [英] What's the path in jblough / Android-Pdf-Viewer-Library?

查看:94
本文介绍了是什么在jblough / Android的-PDF查看器库的路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在以下网站寻找:
https://github.com/jblough/Android-Pdf-Viewer-Library

他列在下code:

 意向意图=新意图(这一点,YourPdfViewerActivity.class);
intent.putExtra(PdfViewerActivity.EXTRA_PDFFILENAME,PATH TO PDF GOES HERE);
startActivity(意向);

会有什么这条道路是在哪里我可以把这个PDF文件?

我已经把测试PDF文件中夹入资产价值,资源/原材料。从数据/数据​​/项目DDMS推了文件,并在libs文件夹也是如此。我尝试以下,但我仍然得到找不到文件:

 字符串路径= Environment.getExternalStorageDirectory()的getPath()。
字符串路径= Environment.getExternalStorageDirectory()getAbsolutePath()+的test.pdf。
字符串路径=android.resource://com.example.test3/raw/test.pdf
字符串路径=文件:///android_assets/test.pdf;
字符串路径= Environment.getExternalStorageDirectory()getAbsolutePath()+/test.pdf。


解决方案

 最后文件cacheDir = context.getDir(缓存,0);
如果cacheDir.mkdirs()(cacheDir.exists()!);
最终文件fil​​eContent =新的文件(cacheDir则为test1.pdf);
字符串路径= Environment.getExternalStorageDirectory()getAbsolutePath()+/test1.pdf。
PATH = fileContent.getPath();
意向意图=新意图(这一点,MainActivity.class);
intent.putExtra(PdfViewerActivity.EXTRA_PDFFILENAME,路径);
startActivity(意向);

运行它第一次,它创建了一个文件夹,然后我把该文件夹中文件并再次运行它,它是能够找到该文件。从DDMS放置在文件。通过Selvin回答。

Looking at the following website: https://github.com/jblough/Android-Pdf-Viewer-Library

He's listed the following code:

Intent intent = new Intent(this, YourPdfViewerActivity.class);
intent.putExtra(PdfViewerActivity.EXTRA_PDFFILENAME, "PATH TO PDF GOES HERE");
startActivity(intent);

What will that path be and where I be placing this PDF file?

I have placed a test PDF file in assests folder, res/raw. Pushed a file from the ddms in data/data/project, and in libs folder as well. I tried the following but I am still getting file not found:

String path = Environment.getExternalStorageDirectory().getPath();
String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "test.pdf";
String path = "android.resource://com.example.test3/raw/test.pdf";
String path = "file:///android_assets/test.pdf";
String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/test.pdf";

解决方案

final File cacheDir = context.getDir("cache", 0);
if(!cacheDir.exists()) cacheDir.mkdirs();
final File fileContent = new File(cacheDir, "test1.pdf");
String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/test1.pdf";
path = fileContent.getPath();
Intent intent = new Intent(this, MainActivity.class);
intent.putExtra(PdfViewerActivity.EXTRA_PDFFILENAME, path);
startActivity(intent);

Ran it first time, it created that folder, then I placed the file in that folder and ran it again and it was able to find the file. Placed the file from the ddms. Answered by Selvin.

这篇关于是什么在jblough / Android的-PDF查看器库的路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆