@Override
 public boolean onKeyDown(int keyCode, KeyEvent event) {
   if (keyCode == KeyEvent.KEYCODE_BACK) {
     ListActivity.info("onKeyDown: not quitting app on back");
     MainActivity.switchTab(this, MainActivity.TAB_LIST);
     return true;
   }
   return super.onKeyDown(keyCode, event);
 }
  public void onAddEvent(View view) {

    // getting Et as a string
    String event_nameET = String.valueOf(event_name.getText());
    String locationET = String.valueOf(location.getText());
    String Start_DateET = String.valueOf(Start_Date.getText());
    String Start_TimeET = String.valueOf(Start_Time.getText());
    String End_DateET = String.valueOf(End_Date.getText());
    String End_TimeET = String.valueOf(End_Time.getText());
    String CategoryName = spinnerCategory.getSelectedItem().toString();
    String TypeName = spinnerType.getSelectedItem().toString();
    String descriptionET = String.valueOf(description.getText());

    // get the latitude and longitude of location
    getLatitudeLongitudeOfLocation(locationET);

    // Read ObjectId from file
    readObjectIdFromFile();

    System.out.println("LatitudeOfLocation........" + LatitudeOfLocation + "...................");
    System.out.println("LongitudeOfLocation........" + LongitudeOfLocation + "...................");

    // check the validatiy of fields
    if (event_nameET.trim().length() == 0) {
      new AlertDialog.Builder(this)
          .setTitle("Warning")
          .setMessage("Please fill the event name!")
          .setNeutralButton("Close", null)
          .show();
    } else if (locationET.trim().length() == 0) {
      new AlertDialog.Builder(this)
          .setTitle("Warning")
          .setMessage("Please fill the location!")
          .setNeutralButton("Close", null)
          .show();
    } else if (Start_DateET.trim().length() == 0) {
      new AlertDialog.Builder(this)
          .setTitle("Warning")
          .setMessage("Please fill the start date!")
          .setNeutralButton("Close", null)
          .show();
    } else if (Start_TimeET.trim().length() == 0) {
      new AlertDialog.Builder(this)
          .setTitle("Warning")
          .setMessage("Please fill the start time!")
          .setNeutralButton("Close", null)
          .show();
    } else if (End_DateET.trim().length() == 0) {
      new AlertDialog.Builder(this)
          .setTitle("Warning")
          .setMessage("Please fill the end date!")
          .setNeutralButton("Close", null)
          .show();
    } else if (End_TimeET.trim().length() == 0) {
      new AlertDialog.Builder(this)
          .setTitle("Warning")
          .setMessage("Please fill the end time!")
          .setNeutralButton("Close", null)
          .show();
    } else if (CategoryName.equals(spinnerCategory.getItemAtPosition(0))) {
      new AlertDialog.Builder(this)
          .setTitle("Warning")
          .setMessage("Please select a suitable category name!")
          .setNeutralButton("Close", null)
          .show();
    } else if (TypeName.equals(spinnerType.getItemAtPosition(0))) {
      new AlertDialog.Builder(this)
          .setTitle("Warning")
          .setMessage("Please select a suitable type name!")
          .setNeutralButton("Close", null)
          .show();
    } else if (descriptionET.trim().length() == 0) {
      new AlertDialog.Builder(this)
          .setTitle("Warning")
          .setMessage("Please fill the description!")
          .setNeutralButton("Close", null)
          .show();
    } else {

      // save to the Parse
      ParseObject testAccount = new ParseObject("TestEvent");
      testAccount.put("Event_Name", event_nameET);
      testAccount.put("Location", locationET);
      testAccount.put("Latitude", LatitudeOfLocation);
      testAccount.put("Longitude", LongitudeOfLocation);
      testAccount.put("Start_Date", Start_DateET);
      testAccount.put("Start_Time", Start_TimeET);
      testAccount.put("End_Date", End_DateET);
      testAccount.put("End_Time", End_TimeET);
      testAccount.put("Category_Name", CategoryName);
      testAccount.put("Type_Name", TypeName);
      testAccount.put("Description", descriptionET);
      testAccount.put("Event_Creater", ObjectIdOfUser);
      testAccount.saveInBackground();

      // Show added message to user
      new AlertDialog.Builder(this)
          .setTitle("Congratulations")
          .setMessage("Your event is successfully added !")
          .setNeutralButton("Continue", null)
          .show();

      // convert them to default value
      event_name.setText("");
      location.setText("");
      Start_Date.setText("");
      Start_Time.setText("");
      End_Date.setText("");
      End_Time.setText("");
      spinnerCategory.setSelection(0);
      spinnerType.setSelection(0);
      description.setText("");

      // Direct user to the my events tab
      MainActivity parentActivity;
      parentActivity = (MainActivity) this.getParent();
      parentActivity.switchTab(4);

      /*
      Intent intent = new Intent(this,MainActivity.class);
      startActivity(intent);
      */
    }
  }