Modify app assets using Phonegap's File API

旧街凉风 提交于 2020-01-22 14:05:47

问题


I worked on a phonegap application using html5 for a month. I handle offline JSON files using File API.
It seems that the JSON files I store are automatically saved on /mnt/sdcard/.

The problem is, I find myself handling 3 files for each file I want.
1 st the file packaged with my app (js/products.js)
2 nd the remote file that sends me updates (http://website/remote_products.js)
3 rd the local file on sdcard I update with the remote data. (/mnt/sdcard/updated-products.js)

Is it possible to - instead of saving on the sdcard - update my app's assets using File API ?
Or create a new file in my app assets folder ?

(the JSON file packaged with my app. Found in js/products.js)

If yes, how plz ?

thx


回答1:


Sadly, you cannot modify the files in /android_assets/www with the File API.

See this answer to a slightly different question answered by one of the PhoneGap Android devs: https://stackoverflow.com/a/8966227/878602

"You can't do what you want to do. The files in the assets directory are not technically on the file system so they are not accessible via the File API. This means calling window. resolveLocalFileSystemURI() will not return you a FileEntry."




回答2:


You might consider to utilize Mott: https://github.com/imlucas/mott, e.g. http://phonegap.com/blog/2013/04/23/story-behind-exfm/

It seems to be able dynamically version, update and persist update of any local asset.



来源:https://stackoverflow.com/questions/9392150/modify-app-assets-using-phonegaps-file-api

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