是否有一个路径类似于文件:/// android_asset /指向的应用程序目录?

问题描述:

我使用的WebView打开保存到应用程序的一些文件。有没有一种方法来链接到保存在运行时文件将是应用程序的目录中,以类似的方式,文件:/// android_asset /呢?通过链接我的意思是使用loadURL(*路*),也正在打开该文件的HTML标记< IMG SRC =*路* />

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*" />

由于反对使用类似文件的绝对路径:///数据/数据​​/ PACKAGENAME /文件/

As oppose to using an absolute path like file:///data/data/PACKAGENAME/files/

使用这种SD卡上的文件:

Use this for files on the SD card:

内容://com.android.htmlfileprovider

content://com.android.htmlfileprovider

在您的资产目录中使用此的文件:

Use this for files in your assets directory:

文件:/// android_asset

file:///android_asset

另外,如果你想有你在你的Web视图中的所有引用使用的基本目录设置的baseUrl场这样的,其中的baseUrl是因为我上面提到的根目录下:

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);