Copying files from android_asset folder to SD Card

ぃ、小莉子 提交于 2019-12-10 23:26:14

问题


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.

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 );

and

window.resolveLocalFileSystemURI(url, success, error);

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

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


回答1:


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



来源:https://stackoverflow.com/questions/22948430/copying-files-from-android-asset-folder-to-sd-card

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!