File not found in webview in android
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");
开发者_如何学Go 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);
}
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
精彩评论