Learn Android Programmatically (Download) Forum

Support Combine text/html file and render in webview

I am working on project which need to display some information in web view, but the file is needed to be generated dynamically by combining two or more file (html/text) stored on internal storage, i am able combine files but not able to render it in webview. Please guide......

String html= CheckLocalHtml(context,"FileName.html");
webViewBasic.loadDataWithBaseURL("file:///",html,"text/html", "utf-8", null);

public String CheckLocalHtml(Context context, String fName) { try { String root = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS).toString(); File mFile, mDir; mDir = new File(root); if (mDir.exists()) { mFile = new File(mDir, fName); if (mFile.exists()) { StringBuilder contentBuilder = new StringBuilder(); BufferedReader in = new BufferedReader(new FileReader(mFile)); String s=""; while ((s = in.readLine()) != null) { contentBuilder.append(s); } in.close(); return contentBuilder.toString(); } else { Toast.makeText(context, "Page not found", Toast.LENGTH_SHORT).show(); } } else { Toast.makeText(context, "Directory not found", Toast.LENGTH_SHORT).show(); } } catch (Exception e) { Log.e("ReadHTML","Error="+e.toString()); } }


#1 chandutayade22389, Sep 11, 2017 Last edited: Sep 11, 2017
I had figured it out.... saved file in storage and used webViewBasic.loadUrl("file:///" + file.getAbsolutePath());
#2 chandutayade22389, Sep 14, 2017