【问题标题】:How to load Html page saved in sdcard on android?如何在android上加载保存在sdcard中的Html页面?
【发布时间】:2010-11-10 05:30:45
【问题描述】:

我在 sdcard 中保存了一些 html 页面。所以,我想通过 webview 显示这些页面。可以帮助完成这项任务吗?

谢谢你, 斯里尼瓦斯

【问题讨论】:

    标签: android html webview


    【解决方案1】:

    您需要一个 ContentProvider,请参阅this page 了解分步操作方法

    【讨论】:

      【解决方案2】:
      1. 将文件读入字符串网站(如http://www.anddev.org/read_a_txt_file_from_sd_card_in_a_real_device-t6619.html

      2. WebView webview = (WebView) findViewById(R.id.my_webview);

      3. webview.loadData(summary, "text/html", "utf-8");

      【讨论】:

        【解决方案3】:

        你可以使用

            webview.loadUrl("file://"+Environment.getExternalStorageDirectory()+"/packagename/files/example.html");
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2018-08-09
          • 2011-06-30
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多