0

I have placed my static web application in an asset folder. My static web application has a lot of folders with files and placed in asset folder. I am calling html from another html with sub folder. I am getting 'file not found'. Can anybody tell me what the problem is? I post my code below:

wv=(WebView)findViewById(R.id.webView);
        //wv.loadDataWithBaseURL("file:///android_asset/Opana_Changes/html/_assets/asset_001/index.html","","html");

       try {
        InputStream is=getAssets().open("Opana_Changes/index.html");
        BufferedReader br=new BufferedReader(new InputStreamReader(is));
        String line = null; 
        while ((line = br.readLine()) != null) { 
            html=html+line;
        } 
        br.close(); 

    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } 

          wv.loadDataWithBaseURL("file:///android_asset/Opana_Changes/",html,"text/html", "UTF-8",null);


        wv.getSettings().setJavaScriptEnabled(true);
        }
Illidanek
  • 996
  • 1
  • 18
  • 32
mohan
  • 13,035
  • 29
  • 108
  • 178

1 Answers1

5

Try the following code if your html file is in assets folder means in assets there is Opana_Changes folder and in Opana_Changes you have your html file. It will work.

wv=(WebView)findViewById(R.id.webView);

wv..loadUrl("file:///android_asset/Opana_Changes/index.html");

Donot forget to vote if my response is helpful for you.

file:///android_asset gives you path upto assets folder.

Can you give the exact folder structure where your file is located

Thanks Deepak

Sunil Kumar Sahoo
  • 53,011
  • 55
  • 178
  • 243
  • In classic Android gradle layout `assets` folder has to be placed inside `main` folder along with `java`, `res` and `AndroidManifest.xml` – ruX Jan 18 '19 at 20:41