获取PhoneGap的绝对路径,以资产的文件夹 [英] Get absolute path to assets folder in PhoneGap

查看:750
本文介绍了获取PhoneGap的绝对路径,以资产的文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法来获得图像的PhoneGap的资源文件夹的绝对路径?

Is there a way to get the absolute path of an image in phonegap asset folder?

我需要的绝对路径使用EmailComposer插件附加图像中的邮件。

I need the absolute path to attach the image in a mail using EmailComposer plugin.

EmailComposer插件,希望像这样的绝对路径:

EmailComposer plugin wants an absolute path like this:

 /storage/sdcard0/DCIM/Camera/20121124_125210.jpg

不过,我要附加的图像在我的资产文件夹,这样的路径:

But the image I want to attach is in my assets folder and a path like this:

file:///android_asset/www/img/logo.png

不能正常工作

does not work

推荐答案

万一有人仍然在寻找一个解决方案。现在科尔多瓦实现了一个非常简单的方法来获取当前应用程序目录(在A​​ndroid,iOS和黑莓10的支持):

Just in case somebody is still looking for a solution. Now Cordova implements a really easy way to get the current application directory (supported on Android, iOS and BlackBerry 10) :

cordova.file.applicationDirectory

例如,如果你想访问你的 RES /音频目录的音频文件(在你的 WWW ),你只要写:

For example, if you want to access an audio file in your res/audio directory (within your www), you just have to write that :

cordova.file.applicationDirectory +RES /音频/我-AUDIO-file.mp3

下面是完整的文档:的https:// github上.COM /阿帕奇/科尔多瓦 - 插件文件/#,其中对存储的文件

这篇关于获取PhoneGap的绝对路径,以资产的文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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