gpt4 book ai didi

android - 有没有类似文件:///android_asset/that points to the apps directory?的路径

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:04:31 27 4
gpt4 key购买 nike

我正在使用 WebView 打开一些保存到应用程序的文件。有没有一种方法可以链接到运行时保存文件的应用程序目录,就像 file:///android_asset/一样?通过链接我的意思是loadUrl( *path* )以及正在打开的文件的 HTML 标记中 <img src="*path*" />

反对使用像 file:///data/data/PACKAGENAME/files/这样的绝对路径

最佳答案

将此用于 SD 卡上的文件:

content://com.android.htmlfileprovider

将此用于 Assets 目录中的文件:

file:///android_asset

另外,如果你想在你的 web View 中使用你的所有引用,请使用该基本目录设置 baseUrl 字段,其中“baseUrl”是我上面提到的根目录:

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

关于android - 有没有类似文件:///android_asset/that points to the apps directory?的路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3921274/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com