How to load html file stored inside SD card in the web view

前端 未结 3 1875
北荒
北荒 2020-12-19 17:03

I have an html file in /mnt/sdcard/packagename/files/something.html path. Now I want to load this file into the webview.

When I surfed for this, I heard something

相关标签:
3条回答
  • 2020-12-19 17:30
    if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){
                Log.d(TAG, "No SDCARD");
    } else {
    webComp.loadUrl("file://"+Environment.getExternalStorageDirectory()+"/packagename/files/something.html");
    }
    
    0 讨论(0)
  • 2020-12-19 17:40

    Check here: http://www.anddev.org/read_a_txt_file_from_sd_card_in_a_real_device-t6619.html

    The methodology is same for html. Loading files from external storage has nothing to do with the content provider.

    Hope this helps!

    0 讨论(0)
  • 2020-12-19 17:46

    try this:

    webview.loadUrl("file:///sdcard/packagename/files/something.html");
    
    0 讨论(0)
提交回复
热议问题