Android从外部存储读取html文件

标签 android android-webview

我正在尝试显示/storage/sdcard0/... 中的 html 文件

WebView engine = (WebView) (findViewById(R.id.webView1));
engine.setWebViewClient(new WebViewClient());
engine.loadUrl(Environment.getExternalStorageDirectory().getPath() + "testing.html");

但是网页无法显示....有人可以帮忙吗?谢谢!

最佳答案

已解决!!! 应该在前面加上"file:///"=]=]

engine.loadUrl("file:///" + 
Environment.getExternalStorageDirectory().getPath() + 
"testing.html");

关于Android从外部存储读取html文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15652524/

相关文章:

android - 适用于 Android 和 iOS 的无服务器嵌入式 noSQL

java - 使用 setOnItemClickListener 接口(interface)时无法从 ListView 接收值

android:动画后 startDrag() 出现 NullpointerException

android - 仅在android中使用wifi获取当前位置

JavaScript 修改 webview 内容后,Android WebView 不刷新

Android:如何在 webview 中从远程加载的 html 页面引用 Assets 图像

android - 具有两个任务的单个 android 应用程序及其导航

javascript - 剪贴板 API 调用抛出 NotAllowedError 而不调用 onPermissionRequest()

android - 在 Android Webview 上运行 create-react-app 的构建

Android Chrome 自定义标签回退