How to load local image in Android WebView

前端 未结 4 1916
情书的邮戳
情书的邮戳 2021-01-05 08:56

I\'m trying to load a html string stored in the database which contain a image into a WebView. The image is stored in the internal memory. I am giving a referen

4条回答
  •  北海茫月
    2021-01-05 09:17

    Try like this

    String base = Environment.getExternalStorageDirectory().getAbsolutePath().toString();
    String imagePath = "file://"+ base + "/image_name.jpg";
    String html = "  ";
    webView.loadDataWithBaseURL("", html, "text/html","utf-8", "");
    

提交回复
热议问题