title: get html string from Webview and store as html file
body: <p>I am trying to load an html string in webview i.e. not from URL or some html file in sdcard. Now the html string has text area. User can edit it. Now I want to save the changes as an html file in internal storage. How do I do it. I have checked other SO questions and all use the same method i.e. using URL or use some javascript method which don't work in my case. </p>
  
  <p>I have tried <a href="https://stackoverflow.com/questions/8200945/how-to-get-html-content-from-a-webview">how to get html content from a webview?</a> but it didn't help me. I think that actually opens popup showing code and doesn't even allow the user to edit which is not my case.</p>
  
  <p>Code (Here the text area is provided by TinyMCE editor):</p>
  
  <pre><code>    try {
          InputStream input = getApplicationContext().getAssets().open("sample.html");
          //Reader is = new BufferedReader( new InputStreamReader(input, "windows-1252"));
  
          StringBuilder contentBuilder = new StringBuilder();
          try {
              BufferedReader in = new BufferedReader( new InputStreamReader(input, "windows-1252"));
              String str;
              while ((str = in.readLine()) != null) {
                  contentBuilder.append(str);
              }
              in.close();
          } catch (IOException e) {
          }
          content = contentBuilder.toString();
  
          content=content.replace("This is some content that will be editable with TinyMCE.", html);
  
          view.getSettings().setJavaScriptEnabled(true);
          view.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
          view.getSettings().setPluginState(WebSettings.PluginState.ON);
          view.addJavascriptInterface(new WebAppInterface(this), "Android");
  
          view.addJavascriptInterface(new MyJavaScriptInterface(this), "HtmlViewer");
  
  
  
          view.setWebViewClient(new WebViewClient() {
              @Override
              public void onPageFinished(WebView view, String url) {
                  view.loadUrl("javascript:window.HtmlViewer.showHTML" +
                          "('&lt;html&gt;'+document.getElementsByTagName('html')[0].innerHTML+'&lt;/html&gt;');");
              }
          });
  
  
          view.loadDataWithBaseURL("file:///android_asset/", content, "text/html",
                  "UTF-8", null);
  </code></pre>