@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_create_diet_chart);

    DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
    Date date = new Date();
    mCurrentDate = dateFormat.format(date);
    mAlarm = "0";

    etDate = (EditText) findViewById(R.id.editDailyDietChartDate);
    etTime = (EditText) findViewById(R.id.editDailyDietChartTime);
    etName = (EditText) findViewById(R.id.editDailyDietChartFeast);
    etDescription = (EditText) findViewById(R.id.editDailyDietChartManu);

    cbAlarm = (CheckBox) findViewById(R.id.diet_alarm);
    btns_save = (Button) findViewById(R.id.btnDietSave);

    // btn_plus = (Button) findViewById(R.id.btnPlus);
    // btn_minus = (Button) findViewById(R.id.btnMinus);
    etDate.setOnClickListener(this);
    etTime.setOnClickListener(this);

    cbAlarm.setOnClickListener(this);
    btns_save.setOnClickListener(this);

    // btn_plus.setOnClickListener(this);
    // btn_minus.setOnClickListener(this);

    Intent mActivityIntent = getIntent();
    mStrActivityID = mActivityIntent.getStringExtra("activityId");

    if (mStrActivityID != null) {
      mActivityId = Long.parseLong(mStrActivityID);

      /*
       * get the activity which include all data from database according
       * profileId of the clicked item.
       */
      mActivityDataSource = new DietChartDataSource(this);
      mUpdateActivity = mActivityDataSource.updateActivityData(mActivityId);

      String mDate = mUpdateActivity.getDate();
      String mTime = mUpdateActivity.getTime();
      String mName = mUpdateActivity.getEventName();
      String mDescription = mUpdateActivity.getFoodMenu();
      String mAlarm = mUpdateActivity.getAlarm();
      long mActivityAlarm = Long.parseLong(mAlarm);

      // set the value of database to the text field.
      etDate.setText(mDate);
      etTime.setText(mTime);
      etName.setText(mName);
      etDescription.setText(mDescription);
      if (mActivityAlarm == 1) {
        cbAlarm.setChecked(!cbAlarm.isChecked());
      }

      /*
       * change button name
       */
      btns_save.setText("Update");
    }
  }
  @Override
  public void onClick(View v) {
    // TODO Auto-generated method stub
    Toast toast = null;
    switch (v.getId()) {
      case R.id.editDailyDietChartDate:
        mYear = mCalendar.get(Calendar.YEAR);
        mMonth = mCalendar.get(Calendar.MONTH);
        mDay = mCalendar.get(Calendar.DAY_OF_MONTH);

        DatePickerDialog dialog = new DatePickerDialog(this, this, mYear, mMonth, mDay);
        dialog.show();
        break;
      case R.id.editDailyDietChartTime:
        // Process to get Current Time

        mHour = mCalendar.get(Calendar.HOUR_OF_DAY);
        mMinute = mCalendar.get(Calendar.MINUTE);

        // Launch Time Picker Dialog
        TimePickerDialog tpd = new TimePickerDialog(this, this, mHour, mMinute, false);
        tpd.show();
        break;

      case R.id.btnDietSave:
        mDate = etDate.getText().toString();
        mTime = etTime.getText().toString();
        mName = etName.getText().toString();

        mDescription = etDescription.getText().toString();

        if (cbAlarm.isChecked()) {
          mAlarm = "1";

          Intent alarmIntent = new Intent(AlarmClock.ACTION_SET_ALARM);
          alarmIntent.putExtra(AlarmClock.EXTRA_MESSAGE, mDescription);
          alarmIntent.putExtra(AlarmClock.EXTRA_HOUR, mSetHour);
          alarmIntent.putExtra(AlarmClock.EXTRA_MINUTES, mSetMinute);
          alarmIntent.putExtra(AlarmClock.EXTRA_SKIP_UI, true);
          alarmIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
          startActivity(alarmIntent);
        }

        DietChartModel activityDataInsert = new DietChartModel();
        activityDataInsert.setDate(mDate);
        activityDataInsert.setTime(mTime);
        activityDataInsert.setEventName(mName);
        activityDataInsert.setFoodMenu(mDescription);

        activityDataInsert.setAlarm(mAlarm);

        /*
         * if update is needed then update otherwise submit
         */
        if (mStrActivityID != null) {

          mActivityId = Long.parseLong(mStrActivityID);

          activityDS = new DietChartDataSource(this);

          if (activityDS.updateData(mActivityId, activityDataInsert) == true) {
            toast = Toast.makeText(this, "Successfully Updated.", Toast.LENGTH_LONG);
            toast.show();

            // Intent intent = new Intent();
            // intent.putExtra("activityID", mStrActivityID);
            // setResult(Activity.RESULT_OK, intent);
            // finish();

            startActivity(
                new Intent(
                    FTFLICareCreateDietChartActivity.this, FTFLICareDietChartActivity.class));
            finish();
          } else {
            toast = Toast.makeText(this, "Not Updated.", Toast.LENGTH_LONG);
            toast.show();
          }
        } else {
          activityDS = new DietChartDataSource(this);
          if (activityDS.insert(activityDataInsert) == true) {
            toast = Toast.makeText(this, "Successfully Saved.", Toast.LENGTH_LONG);
            toast.show();

            startActivity(
                new Intent(FTFLICareCreateDietChartActivity.this, FTFLICareHomeActivity.class));
            /*					startActivity(new Intent(
            ICareCreateDietChartActivity.this,
            ICareDietChartListActivity.class));*/
            // finish();
          } else {
            toast = Toast.makeText(this, "Not Saved.", Toast.LENGTH_LONG);
            toast.show();
          }
        }
        break;
    }
  }