我有一個文件保存在根文件夾中,並試圖在Web視圖中打開它。在Webview中打開本地Html文件 - Android
這是我保存代碼:
OutputStream outstream = null;
outstream = openFileOutput(fileName ,MODE_WORLD_READABLE);
/// if file the available for writing
if (outstream != null) {
/// prepare the file for writing
OutputStreamWriter outputreader = new OutputStreamWriter(outstream);
BufferedWriter buffwriter = new BufferedWriter(outputreader);
/// write the result into the file
buffwriter.write(result);
}
/// close the file
outstream.close();
} catch (java.io.FileNotFoundException e) {
System.out.println("File not found in the writing...");
} catch (IOException e) {
System.out.println("In the writing...");
}
這是我回顧文件代碼:
fileView.getSettings().setJavaScriptEnabled(true);
fileView.loadUrl("file:///" + name); <---
,並在應用程序中它給了我找不到錯誤的文件。
任何見解都有幫助。
我想對製作遊戲的Android入門。從理論上講,我可以創建一個html5 canvas和javascript遊戲,將這些文件存儲在android手機的本地文件中,然後用webview打開它們讓玩家玩遊戲? – Jacob 2011-11-02 19:47:07