开发者

Android: Webview loading URL failed?

I am able to run a code that copies files and folders from one directory to another, I have the ff.input:

Source: new File(Environment.getExternalStorageDirectory(), "E_BU/EngagiaDroid") which gives the output /mnt/sdcard/E_BU/EngagiaDroid on my device, AND, Destination: new File(Environment.getExternalStorageDirectory(), "EngagiaDroid") which gives the output /mnt/sdcard/EngagiaDroid on my device.

However, when I used the webview code in this link to view my html using: Environment.getExternalStorageDirectory() + "/EngagiaDroid/videos.html" which gives the output /mnt/sdcard/EngagiaDroid/videos.html, webview was not able to load that url. But when I change the url to other url for example http://codeofaninja.blogspot.com/2011/05/how-to-view-webpage-inside-your-android.html, it was able to load, meaning the webview code works.

I'm sure that t开发者_运维技巧he files were copied.


I assume you have the READ_EXTERNAL_STORAGE permission. Have you set webView.getSettings().setAllowFileAccess(true); on the WebView?

Other than that, the most likely thing would be a problem with the URL. It should start with file:///, for one thing. Maybe something like:

"file://" + Environment.getExternalStorageDirectory() + "/EngagiaDroid/videos.html"

Examples I've seen often come out to file:///sdcard/...


wView.loadUrl("file://sdcard/About_Eng.htm");

Use this l ine and its work

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜