码迷,mamicode.com
首页 > 其他好文 > 详细

文件下载cordovaFileTransfer:cordova.file.documentsDirectory is null

时间:2015-05-20 12:41:06      阅读:369      评论:0      收藏:0      [点我收藏+]

标签:

在Android平台上使用:$cordovaFileTransfer进行文件下载时提示:cordova.file.documentsDirectory is null,查了以下文档参照:http://ngcordova.com/docs/plugins/file/,

documentsDirectory是IOS平台的用法,在Android平台上没有此方法所以获取到null,解决方法:

通过使用:$cordovaDevice.getPlatform()获取应用平台,针对不同平台进行文件下载处理:

IOS使用:cordova.file.documentsDirectory

Android使用:cordova.file.externalRootDirectory

iOS File System Layout
Device Pathcordova.file.*iosExtraFileSystemsr/w?persistent?OS clearssyncprivate
/var/mobile/Applications/<UUID>/ applicationStorageDirectory - r N/A N/A N/A Yes
    appname.app/ applicationDirectory bundle r N/A N/A N/A Yes
        www/ - - r N/A N/A N/A Yes
    Documents/ documentsDirectory documents r/w Yes No Yes Yes
        NoCloud/ - documents-nosync r/w Yes No No Yes
    Library - library r/w Yes No Yes? Yes
        NoCloud/ dataDirectory library-nosync r/w Yes No No Yes
        Cloud/ syncedDataDirectory - r/w Yes No Yes Yes
        Caches/ cacheDirectory cache r/w Yes* Yes*** No Yes
    tmp/ tempDirectory - r/w No**
Android File System Layout
Device Pathcordova.file.*AndroidExtraFileSystemsr/w?persistent?OS clearsprivate
file:///android_asset/ applicationDirectory   r N/A N/A Yes
/data/data/<app-id>/ applicationStorageDirectory - r/w N/A N/A Yes
    cache cacheDirectory cache r/w Yes Yes* Yes
    files dataDirectory files r/w Yes No Yes
        Documents   documents r/w Yes No Yes
<sdcard>/ externalRootDirectory sdcard r/w Yes No No
    Android/data/<app-id>/ externalApplicationStorageDirectory - r/w Yes No No
        cache externalCacheDirectry cache-external r/w Yes No** No
        files externalDataDirectory files-external r/w

文件下载cordovaFileTransfer:cordova.file.documentsDirectory is null

标签:

原文地址:http://www.cnblogs.com/yshyee/p/4516662.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!