I have some files stored in the app's "internal storage", which is located on the device here:
/data/data//files/
Here's the problem: I want to reference these files from the webview. How do I do this? What should I use as the baseUrl?
I need something similar to file:///android_asset but for "internal storage" instead开发者_运维问答 of for files in the assets directory.
Try this:
file:///data/data/com.yourproject.example/files/image.png
You should use Context.getFilesDir() when generating the path, not hard coding the application's files-path. This will ensure that the application will still work even if your package/namespace changes.
Example:
String filesPath = getFilesDir().getAbsolutePath();
String filePath = "file://" + filesPath + "/image.png";
精彩评论