Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

530
Views
Android, javascript in WebView: how to get file from disk?

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.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!