I have a index.html + javascript code in the ‘assets’ folder of my apk. When the app is launched, I open index.html in a webview ; the html page is displayed properly and the basic javascript code is also properly executed.
To open index.html in my webview, I use the following code:
webView.loadUrl("https://appassets.androidplatform.net/assets/www/examples/index.html");
At runtime, a .txt file is created by the app and placed on the disk of my Android phone at:
file:///storage/emulated/0/Android/data/com.example.test/files/www/mytextfile.txt
Now, I have a button in my index.html page. When I click on this button, I want to execute a javascript function that will process some tasks on mytextfile.txt and display it on my html page in the webview.
So I execute in javascript something like this when the user clicks on the button:
doStuffOnDiskTxtFile('file:///storage/emulated/0/Android/data/com.example.test/files/www/mytextfile.txt')
But I get the following error:
"Fetch API cannot load file:///storage/emulated/0/Android/data/com.example.test/files/www/mytextfile.txt.
URL scheme "file" is not supported.",
source: https://appassets.androidplatform.net/assets/www/build/module.js
Any idea how to solve this issue ? Would it work better if my html + javascript code were hosted on a distant server and not ran locally ?
Thanks for your help.