Cordova在Android上打开本地Pdf文件 [英] Cordova open local Pdf file on Android

查看:920
本文介绍了Cordova在Android上打开本地Pdf文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将文件下载到文件夹 dataDirectory < a>。
文档存在,其路径如下:

I have downloaded a file into the folder "dataDirectory". The document exists and its path is something like:

file:///data/data/app_id/files/file_name.pdf 

因此,当我尝试使用 cordova-open
在选择acrobat reader后,我发现错误Not valid path。

so, when I'm trying to open it with cordova-open after selecting acrobat reader I recive an error "Not valid path".

localFile = "file:///data/data/app_id/files/file_name.pdf"
cordova.plugins.disusered.open(localFile, function(){}, function({});

解决方案:
使用 cordova.file.externalDataDirectory

推荐答案

/ data / data /< package> / 内部存储,并且只有已创建的应用程序具有访问权限,您需要使用外部存储设备在其他应用程序之间共享文件,或者您可以实现文件共享功能。

/data/data/<package>/ is basically an internal storage and only the app for which it has been created has access for it. You will either need to use the external storage to share the file among other apps or you can implement the File Sharing feature .

http://developer.android .com / training / secure-file-sharing / setup-sharing.html

这篇关于Cordova在Android上打开本地Pdf文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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