问题
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