Ejemplo n.º 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();
    }
  }