Hướng dẫn open local html file android webview - mở tệp html cục bộ cho android webview

14

Mới! Lưu câu hỏi hoặc câu trả lời và sắp xếp nội dung yêu thích của bạn. Tìm hiểu thêm.
Learn more.

Tôi đã lưu một tệp trong thư mục gốc và đang cố gắng mở nó trong một WebView.

Đây là mã của tôi để lưu:

    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..."];
}

Đây là mã của tôi để nhớ lại tệp:

                    fileView.getSettings[].setJavaScriptEnabled[true];
            fileView.loadUrl["file:///" + name]; 

Bài Viết Liên Quan

Chủ Đề