title: Clearing cache programmatically?
body: <p>I have already seen the other questions but i want something different and simpler(i think).</p>
  
  <p>I have an activity that on click sends to the email address that you have entered a welcome email using java mail api. To be more specific when it first runs you enter your gmail account with your password and the address where the welcome email is sent. Now when i put a wrong password an exception is created and you have asked to put your real pass or username. But if i put my real one it asks me again to do that. In addition if i put my real one and then cange it it continues to send the welcome mail. How can i fix this? Here is a sample code:</p>
  
  <pre><code>EmailValidator val = new EmailValidator();                   
  
      Boolean a = val.validate(yemail);
      Boolean b = val.validate(temail);
      if (a == false || b == false){
          AlertDialog.Builder box = new AlertDialog.Builder(this);
  
          // Set the message to display
      box.setMessage("Please enter a valid email address!");
  
              // Add a neutral button to the alert box and assign a click listener
      box.setNeutralButton("Ok", new DialogInterface.OnClickListener()        {
  
                  // Click listener on the neutral button of alert box
      public void onClick(DialogInterface arg0, int arg1)             {
  
      Toast.makeText(getApplicationContext(), "OK", Toast.LENGTH_LONG).show();
                                                                      }                   
                                                                              });
                              box.show();
                                  }// end if validating emails
      if (a == true &amp;&amp; b == true &amp;&amp; ypass != null){
          try { // send mail
              GmailSender sender = new GmailSender(yemail,ypass); // SUBSTITUTE HERE                
              sender.sendMail(
                                  "EMERGENCY",   //subject.getText().toString(), 
                                  "hi",                  //body.getText().toString(), 
                                  "stathias7@hotmail.com",                      //from.getText().toString(),
                                  temail //to.getText().toString() address where the mail is sent to
                              );
  
              } 
      catch (Exception e) {
          AlertDialog.Builder box = new AlertDialog.Builder(this);
  
          // Set the message to display
      box.setMessage("Please Re-enter your Gmail username and pasword");
  
              // Add a neutral button to the alert box and assign a click listener
      box.setNeutralButton("Ok", new DialogInterface.OnClickListener() {
  
                  // Click listener on the neutral button of alert box
      public void onClick(DialogInterface arg0, int arg1) {
  
                  Toast.makeText(getApplicationContext(), "OK", Toast.LENGTH_LONG).show();
                                                                      }                   
                                                                              });
                              box.show();
                          } // end catching Exception
  
                                                      } // try to send mail
  
  }
  </code></pre>