Is there a path similar to file:///android_asset/ that points to the apps directory?

后端 未结 2 1574
南旧
南旧 2021-02-06 04:47

I\'m using a WebView to open some files saved to the app. Is there a way to link to the app\'s directory where files saved at runtime would be, in a similar way that file:///an

2条回答
  •  不要未来只要你来
    2021-02-06 05:09

    Use this for files on the SD card:

    content://com.android.htmlfileprovider

    Use this for files in your assets directory:

    file:///android_asset

    Also, if you want to have all your references in your web view use that base directory set the baseUrl field like this, where "baseUrl" is the root directory as I mentioned above:

    webview.loadDataWithBaseURL(
            baseUrl, htmlText, "text/html", "UTF-8", null);
    

提交回复
热议问题