admin 管理员组文章数量: 1086019
I am looking for an elegant way to access local files (either on phone memory or SD Card) on an Android device from JavaScript running in WebView on an Android device.
I am loading said WebView with a html page from the device located in the assets folder. Along these lines, I believe I can access any file in this assets folder from the Javascript, but can't load anything from SD card or phone memory. I am aware of the addJavaScriptInterface, but I am specifically trying to load images, so using this method would require some tweaking to pass a B64 encoded image.
I am new to Android development, and want to make sure I am not missing something obvious.
I am looking for an elegant way to access local files (either on phone memory or SD Card) on an Android device from JavaScript running in WebView on an Android device.
I am loading said WebView with a html page from the device located in the assets folder. Along these lines, I believe I can access any file in this assets folder from the Javascript, but can't load anything from SD card or phone memory. I am aware of the addJavaScriptInterface, but I am specifically trying to load images, so using this method would require some tweaking to pass a B64 encoded image.
I am new to Android development, and want to make sure I am not missing something obvious.
Share Improve this question asked Nov 26, 2010 at 13:43 user163757user163757 7,0259 gold badges33 silver badges48 bronze badges2 Answers
Reset to default 3You need to implement a ContentProvider to map local files to uris.
Android tip #1 ContentProvider , Accessing local file system from WebView / showing image in webview using content://
本文标签: Android Access Local File From WebView JavascriptStack Overflow
版权声明:本文标题:Android Access Local File From WebView Javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1744042492a2523515.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论