从android_asset文件夹复制到SD卡复制文件 [英] Copying files from android_asset folder to SD Card

查看:573
本文介绍了从android_asset文件夹复制到SD卡复制文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我要玩那些在科尔多瓦的应用程序捆绑的视频文件。要做到这一点,我要他们搬出 android_asset 文件夹和到SD卡上。我想,如果在所有可能通过文件API为此在JS,

So, I want to play video files that are bundled in a Cordova app. To do that, I have to move them out of the android_asset folder and onto the SD card. I'd like to do this in JS via the File API, if at all possible.

话虽这么说,我似乎无法从我的科尔多瓦的WebView该文件夹阅读。

That being said, I seem to be unable to read from that folder with my Cordova WebView.

我已经尝试了几种不同的方法,但这里有两个,基于我读过,的的工作:

I've tried a few different methods, but here are the two that, based on what I've read, should work:

var url = 'file:///android_asset/www/my_video_folder';
var sourceDir = new DirectoryEntry( { fullPath: url } );
var reader = sourceDir.createReader();
reader.readEntries( success, error );

window.resolveLocalFileSystemURI(url, success, error);

在这两种情况下,错误回调被调用,以错误。code == 5 FileError.ENCODING_ERR )。

In both cases, the error callback is called, with error.code == 5 (FileError.ENCODING_ERR).

是我在做什么刚才的无法的?难道我的文件在Java code复制?

Is what I'm doing just not possible? Do I have to copy the files in the Java code?

推荐答案

对于任何一个仍然获得困难,有能达致这一个插件
https://github.com/gkcgautam/Asset2SD

For any one still getting difficulties, there is a plugin which can acheive this https://github.com/gkcgautam/Asset2SD

这篇关于从android_asset文件夹复制到SD卡复制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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