Exemple #1
0
  public void save() {
    //
    //        Intent intent=getIntent();
    //        profileId=intent.getIntExtra("profile_id",0);

    // icareDS=new ProfileDataSource(getApplicationContext());

    //        HashMap<String, String> map = new HashMap<String, String>();
    //        map= icareDS.getAboutOneProfile(profileId);
    //        Log.v("map value", map.toString());

    mName = etName.getText().toString();
    mAge = etAge.getText().toString();
    mBloodGroup = String.valueOf(etBloodGroup.getSelectedItem());
    mWeight = etWeight.getText().toString();
    mHeight = etHeight.getText().toString();
    mDateOfBirth = etDateOfBirth.getText().toString();
    mSpecialNotes = etSpecialNotes.getText().toString();

    // Assign values in the ICareProfile
    Profile profileDataInsert =
        new Profile(mName, mAge, mBloodGroup, mWeight, mHeight, mDateOfBirth, mSpecialNotes, image);
    profileDataInsert.setName(mName);
    profileDataInsert.setAge(mAge);
    profileDataInsert.setBloodGroup(mBloodGroup);
    profileDataInsert.setWeight(mWeight);
    profileDataInsert.setHeight(mHeight);
    profileDataInsert.setDateOfBirth(mDateOfBirth);
    profileDataInsert.setSpecialNotes(mSpecialNotes);
    profileDataInsert.setImage(image);

    /*
     * if update is needed then update otherwise submit
     */
    icareDS = new ProfileDataSource(getBaseContext());
    if (icareDS.insert(profileDataInsert)) {
      toast = Toast.makeText(this, getString(R.string.successfullySaved), Toast.LENGTH_LONG);
      toast.show();
      startActivity(new Intent(ProfileCreate.this, MainActivity.class));
    } else {
      toast = Toast.makeText(this, getString(R.string.notSaved), Toast.LENGTH_LONG);
      toast.show();
    }
  }
        public void onClick(View v) {
          mName = et_name.getText().toString();
          mAge = et_age.getText().toString();
          mBloodGroup = etBloodGroup.getText().toString();
          mWeight = et_weight.getText().toString();
          mHeight = et_height.getText().toString();
          mDateOfBirth = et_dateOfBirth.getText().toString();
          mSpecialNotes = et_specialNotes.getText().toString();

          // Assign values in the ICareProfile
          Profile profileDataInsert = new Profile();
          profileDataInsert.setName(mName);
          profileDataInsert.setAge(mAge);
          profileDataInsert.setBloodGroup(mBloodGroup);
          profileDataInsert.setWeight(mWeight);
          profileDataInsert.setHeight(mHeight);
          profileDataInsert.setDateOfBirth(mDateOfBirth);
          profileDataInsert.setSpecialNotes(mSpecialNotes);

          mDataSource = new ProfileDataSource(getBaseContext());

          if (mDataSource.updateData(1, profileDataInsert) == true) {
            Intent intent = new Intent(ProfilePreviewUpdate.this, MainActivity.class);
            startActivity(intent);
            toast =
                Toast.makeText(
                    ProfilePreviewUpdate.this,
                    getString(R.string.successfullyUpdated),
                    Toast.LENGTH_LONG);
            toast.show();
            // displayView();

          } else {
            toast =
                Toast.makeText(
                    ProfilePreviewUpdate.this, getString(R.string.notUpdated), Toast.LENGTH_LONG);
            toast.show();
          }
        }