I am porting an iOS application to Android and have run into resource access issues.
Ideally, I'd like to open supplemental files (in this case PDFs, MP4 movies, etc.) in the application; however, I have discovered that Android+Cordova does not work as seamlessly as iOS+Cordova in this fashion.
Knowing (and accepting) that I need to pass files of this sort off to a secondary application, I have encountered the obvious permissions issues (i.e. external resources cannot see inside the resource bundle/APK).
I figured I could copy the resource out to a user folder on the device using the Cordova File plugin, and then use something like the FileOpener plugin; however, the File plugin can access the device file system -- but not pull from the APK.
I have hopes that the Asset2SD plugin (https://github.com/gkcgautam/Asset2SD) may help here, since it has been recently updated to Cordova 3.
Is there a more appropriate/preferred means of doing this kind of thing? I have to think it's a relatively common task, but there doesn't seem to be much on the topic (short of "find another way...").
NOTE: I've already reached out to the PhoneGap/Cordova community (https://groups.google.com/forum/#!topic/phonegap/xh_4UrEl9Gw), but haven't had much success there.
EDIT-1: Additionally, file size on the APK is going to exceed the 50MB cap, requiring extension APKs. I've mentioned this in the off chance that this might make things simpler.
EDIT-2: I've managed to get my base APK size down and have redistributed some resources so that an expansion APK (OBB) isn't necessary. I have also managed to make use of Asset2SD to successfully extract resource. My remaining issue is pathing.
The code looks like so...
window.plugins.asset2sd.startActivity(
{
asset_file: "www/folder/" + filename,
destination_file_location: "MyApp/myfolder/",
destination_file: filename
},
// success on saving file
function(filename) {
window.plugins.fileOpener.open("file:///" + filename);
},
// failure on saving file
function() {
console.log("Could not open file");
}
);
I know that Asset2SD uses getExternalStorageDirectory() [Google seems to advocate using getExternalFilesDir() in their discussion on expansion APKs].
EDIT-3: Sorted out return value from Asset2SD (i.e. filename + path) which can be pushed to FileOpener. Code updated accordingly.