title: WebView cookies not working
body: <p>Before saying this is a duplicate, none of the solutions around stackoverflow worked for me.
  I have an app which has a button.
  Once the button is clicked, a webviewActivity with a webview is opened.
  It has a login, and when I type my login and try to access the rest of the website (with my credentials already on) I cant due to not been logged in.</p>
  
  <p>Here is my WebViewActivity</p>
  
  <pre><code>public class WebViewActivity extends Activity {
  
      private WebView webView;
      private static byte[] finaldata;
      FileInputStream finall = null;
      private static boolean loopSleep = false;
  
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.webview);
  
          webView = (WebView) findViewById(R.id.webView1);    
  
          CookieSyncManager.createInstance(this);
          CookieManager cookieManager = CookieManager.getInstance();
          cookieManager.removeAllCookie();
          cookieManager.setAcceptCookie(true);
  
          webView.setWebViewClient(new MyWebViewClient());
          WebSettings ws = webView.getSettings();
          ws.setSaveFormData(false);
  
          webView.getSettings().setJavaScriptEnabled(true);
          webView.getSettings().setDatabaseEnabled(true);
          String dbPath = this.getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
          webView.getSettings().setDatabasePath(dbPath);
          webView.getSettings().setDomStorageEnabled(true);
          setContentView(webView);
          webView.loadUrl("http://192.168.1.33:8080/formsvi/login.html");
  
      }
  
      private class MyWebViewClient extends WebViewClient {
          @Override
          public WebResourceResponse shouldInterceptRequest (final WebView view, String url) {
              if (url.contains("TAKEPICWITHCAMERA")) 
              {
                  //OPEN CAMERA AND TAKE PICTURE              
                  Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                  if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
                      startActivityForResult(takePictureIntent, 1);
                  }
                  while (!loopSleep)
                  {
                      try
                      {
                          Thread.sleep(1000);
                      }
                      catch (InterruptedException e)
                      {
                          e.printStackTrace();
                      }        
                  }  
                  loopSleep = false;
                  InputStream is = new ByteArrayInputStream(finaldata);
                  return new WebResourceResponse("text/html", "UTF-8", is);    
               }          
              else
              {
                  return null;
              }               
          }
      }
  
      }
  </code></pre>
  
  <p>Hope the camera code or the <code>shouldInterceptRequest</code> I have has nothing to do with this problem.</p>