Load WebView with .html file linked to /assets folder

寵の児 提交于 2019-12-11 13:38:45

问题


I need to load .html file into WebView but this file is situated in external folder on disk. I cannot copy file into /assets folder under my android project. But i can create a link to this file in Eclipse.

The question is how can i load this linked file into WebView?

I tried to load it with webView.loadUrl("file:///android_asset/myFile.html") but it did work. WebView cannot find 'myFile.html' in '/assests' folder. ('myFile.html' link in /assests folder to real file in external folder on disk.)

Please give any idea!!!! Thanks in advance!


回答1:


If you are on OS X or Linux, try creating a symlink into your project assets/ for the file in question. I doubt that an Eclipse link will be sufficient, as packaging assets into the APK is not Eclipse's job, and the Android tools invoked by Eclipse may not know about Eclipse links.




回答2:


For windows use this command mklink /D link-folder-name target-folder. The eclipse/android work fine with this link and your apk will have all the linked resources.



来源:https://stackoverflow.com/questions/5648493/load-webview-with-html-file-linked-to-assets-folder

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