how to get age and use it in another activity?
<p>I'm developing an android app for babies and after the user sets the birth date of the baby, i need to save it so i can use it in another activity such as sleep and vaccinations.
I have used the Shared Preference to save the data enters by the user.
but i haven't figure out how to get that data and use it in other classes. can u help me please?</p>

<p>here is the code for the baby data required</p>

<pre><code>public class MainActivity extends Activity {
private Button change;
private ImageView bImage;
private Button mPickDate;
private int mYear;
private int mMonth;
private int mDay;
static final int DATE_DIALOG_ID = 0;
     // get the current date
        final Calendar c = Calendar.getInstance();
        mYear = c.get(Calendar.YEAR);
        mMonth = c.get(Calendar.MONTH);
        mDay = c.get(Calendar.DAY_OF_MONTH);

        updateDateDisplay();


}
   private void updateDateDisplay() {

        this.mPickDate.setText(
        new StringBuilder()
        .append(mMonth + 1).append("-")
        .append(mDay).append("-")
        .append(mYear).append(" "));
        }
   public int getAge (int _year, int _month, int _day) {

       GregorianCalendar cal = new GregorianCalendar();
       int y, m, d, a;         

       y = cal.get(Calendar.YEAR);
       m = cal.get(Calendar.MONTH) + 1;
       d = cal.get(Calendar.DAY_OF_MONTH);
       cal.set(_year, _month, _day);
       a = y - cal.get(Calendar.YEAR);
       if ((m &lt; cal.get(Calendar.MONTH))
                       || ((m == cal.get(Calendar.MONTH)) &amp;&amp; (d &lt; cal
                                       .get(Calendar.DAY_OF_MONTH)))) {
               --a;
       }
       if(a &lt; 0)
               throw new IllegalArgumentException("Age &lt; 0");
       return a;
       }



    // the callback received when the user “sets” the date in the dialog
    private DatePickerDialog.OnDateSetListener mDateSetListener =
    new DatePickerDialog.OnDateSetListener() {

    public void onDateSet(DatePicker view, int year,
    int monthOfYear, int dayOfMonth) {
    mYear = year;
    mMonth = monthOfYear;
    mDay = dayOfMonth;
    updateDateDisplay();
    }

    };


    @Override
    protected Dialog onCreateDialog(int id) {
    switch (id) {
    case DATE_DIALOG_ID:
    return new DatePickerDialog(this,
    mDateSetListener,
    mYear, mMonth, mDay);
    }
    return null;
    }
</code></pre>
