是否有类似于 file:///android_asset/ 的路径指向 apps 目录?
我正在使用 WebView 打开保存到应用程序的一些文件。有没有一种方法可以链接到应用程序的目录,在运行时保存的文件将在该目录中,类似于 file:///android_asset/ 的方式?我所说的链接是指 loadUrl( *path* )
以及正在打开的文件的 HTML 标记
与此相反使用绝对路径,例如 file:///data/data/PACKAGENAME/files/
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:///android_asset/ does? By link I mean loadUrl( *path* )
and also in the HTML markup of the file being opened <img src="*path*" />
As oppose to using an absolute path like file:///data/data/PACKAGENAME/files/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将其用于 SD 卡上的文件:
将其用于资产目录中的文件:
另外,如果您想在 Web 视图中使用该基本目录中的所有引用,请像这样设置 baseUrl 字段,其中“baseUrl”是我上面提到的根目录:
Use this for files on the SD card:
Use this for files in your assets directory:
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:
从 android 2.1 开始,他们添加了
对 SD 卡上文件的支持,
因此:
from android 2.1, they've added the
support for files on the sdcard
so :