title: How to make Android webview remember username and password?
body: <p>Here with the code in Android Studio.  I also add the html code that below the Android Studio code, using javascript to remember the username and password in cookies. It works in some android device only. I don'y know why. I would like to make it works for all the android device.
  Hope it will be a simple way to do it. Please kindly help.
  I want the user typed in his username/password one time, it should be filled out on next visit.</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
      private Toolbar toolbar;
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
  
          toolbar = (Toolbar) findViewById(R.id.app_bar);
          setSupportActionBar(toolbar);
          getSupportActionBar().setTitle("Go To Our Facebook Page");
  
          WebView myWebView = (WebView) findViewById(R.id.webview);
          myWebView.setWebViewClient(new WebViewClient());
          WebSettings webSettings = myWebView.getSettings();
          webSettings.setJavaScriptEnabled(true);
          myWebView.loadUrl("http://www.hksalonjob.comslogin.php");
  
      }
  </code></pre>
  
  <p>here with the html code, using javascript to remember the username and password.</p>
  
  <pre><code>    &lt;!DOCTYPE HTML&gt;
  
      &lt;html&gt;
          &lt;head&gt;
              &lt;title&gt;Salon Job HK&lt;/title&gt;
              &lt;meta http-equiv="content-type" content="text/html; charset=utf-8" /&gt;
              &lt;meta name="description" content="" /&gt;
              &lt;meta name="keywords" content="" /&gt;
              &lt;!--[if lte IE 8]&gt;&lt;script src="css/ie/html5shiv.js"&gt;&lt;/script&gt;&lt;![endif]--&gt;
              &lt;script src="js/jquery.min.js"&gt;&lt;/script&gt;
              &lt;script src="js/jquery.scrolly.min.js"&gt;&lt;/script&gt;
              &lt;script src="js/jquery.dropotron.min.js"&gt;&lt;/script&gt;
              &lt;script src="js/jquery.scrollex.min.js"&gt;&lt;/script&gt;
              &lt;script src="js/skel.min.js"&gt;&lt;/script&gt;
              &lt;script src="js/skel-layers.min.js"&gt;&lt;/script&gt;
              &lt;script src="js/init.js"&gt;&lt;/script&gt;
              &lt;script src="http://code.jquery.com/jquery-1.9.1.js"&gt;&lt;/script&gt;
              &lt;noscript&gt;
                  &lt;link rel="stylesheet" href="css/skel.css" /&gt;
                  &lt;link rel="stylesheet" href="css/style.css" /&gt;
                  &lt;link rel="stylesheet" href="css/style-xlarge.css" /&gt;
              &lt;/noscript&gt;
              &lt;!--[if lte IE 9]&gt;&lt;link rel="stylesheet" href="css/ie/v9.css" /&gt;&lt;![endif]--&gt;
              &lt;!--[if lte IE 8]&gt;&lt;link rel="stylesheet" href="css/ie/v8.css" /&gt;&lt;![endif]--&gt;
  
          &lt;/head&gt;
          &lt;body&gt;
  
              &lt;!-- Header --&gt;
  
  
              &lt;!-- Main --&gt;
  
  
  
          &lt;div id="main" class="wrapper style1"&gt;
          &lt;div class="container"&gt;
  
  
            &lt;form ACTION="&lt;?php echo $loginFormAction; ?&gt;" name="form1" method="POST"&gt;
  
  
  
                                          &lt;div class="12u$"&gt;
                                            &lt;input type="tel" name="tel" required id="tel"  pattern="[0-9]{1}[0-9]{7}"  maxlength="8" value="" placeholder="phone number"/&gt;
                                          &lt;/div&gt;
                                          &lt;br&gt;
  
                                          &lt;div class="12u$"&gt;
                                            &lt;input type="password" name="spassword" required id="spassword"  maxlength="8" placeholder="" /&gt;
                                          &lt;/div&gt;
  
                                          &lt;br&gt;
                                          &lt;div class="12u$"&gt;
                                          &lt;input type="checkbox" name="sremember" id="sremember" /&gt;
                                          &lt;label for="sremember"&gt;Remember me&lt;/label&gt;
  
                                          &lt;/div&gt;
  
  
                            &lt;INPUT Type="submit" class="button special fit" name="Login" id="Login" value="login"&gt;
  
              &lt;/form&gt;  
  
  
              &lt;script&gt;
              //remember username and password
                          $(function() {
  
                              if (localStorage.chkbx &amp;&amp; localStorage.chkbx != '') {
                                  $('#sremember').attr('checked', 'checked');
                                  $('#tel').val(localStorage.tel);
                                  $('#spassword').val(localStorage.spassword);
                              } else {
                                  $('#sremember').removeAttr('checked');
                                  $('#tel').val('');
                                  $('#spassword').val('');
                              }
  
                              $('#sremember').click(function() {
  
                                  if ($('#sremember').is(':checked')) {
                                      // save username and password
                                      localStorage.tel = $('#tel').val();
                                      localStorage.spassword = $('#spassword').val();
                                      localStorage.chkbx = $('#sremember').val();
                                  } else {
                                      localStorage.tel = '';
                                      localStorage.spassword = '';
                                      localStorage.chkbx = '';
                                  }
                              });
                          });
  
              &lt;/script&gt;
  
          &lt;/div&gt;
          &lt;/div&gt;
  
      &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>