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";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With