Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

533
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda