我已将静态 Web 应用程序放置在 asset 文件夹中。我的静态 Web 应用程序有很多包含文件的文件夹,并放置在 asset 文件夹中。我正在从另一个带有子文件夹的 html 调用 html。我收到“找不到文件”。谁能告诉我问题是什么?我在下面发布我的代码:
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);
}
Run Code Online (Sandbox Code Playgroud)
如果您的 html 文件位于 asset 文件夹中,请尝试以下代码,这意味着在 asset 中存在 Opana_Changes 文件夹,并且在 Opana_Changes 中您有 html 文件。它会起作用的。
wv=(WebView)findViewById(R.id.webView);
wv..loadUrl("file:///android_asset/Opana_Changes/index.html");
Run Code Online (Sandbox Code Playgroud)
如果我的回答对你有帮助,别忘了投票哦。
file:///android_asset gives you path upto assets folder.
Run Code Online (Sandbox Code Playgroud)
您能否给出文件所在的确切文件夹结构
谢谢迪帕克
| 归档时间: |
|
| 查看次数: |
3376 次 |
| 最近记录: |