Reputation: 5667
I have working js code that loads a bunch of files using XHR. On PC Chrome it just works (with the Chrome flag that allows loading local files) and it also worked on android, if I put the files inside the apk.
However those files are huge and having phonegap send them to my android device each time I want to debug the apk is a pain. I figured, if I could move those files to the SD card on my android device I could debug it faster.
I know phonegap has plugins for loading files and do various other magic, but I hoped not to have to rewrite the file loading methods or at least not at this stage (the code wasn't exactly written by me to begin with).
So can I use XHR to load local files (from SD Card) in a Phonegap app on android?
Upvotes: 1
Views: 816
Reputation: 5667
After a lot of testing I can say with utmost confidence that XHR can be used to load local files (from SD card) without any particular changes in project configuration, however... XHR cannot be used in the phonegap development app (other than for loading internal files from the app). Those files can be only loaded if phonegap app runs from localhost, however when you use the development app it runs on your computer and as such from a different domain\IP address. The webview on a mobile device will block those requests due to cross domain rules.
Upvotes: 1