title: extract date Datepicker Android
body: <p>I've been trying to extract the date that I get with the <code>Datepicker</code> as it says <a href="http://developer.android.com/intl/es/guide/topics/ui/controls/pickers.html" rel="nofollow">here</a>  The problem comes when I try to use a function that I've created (getDate), I can't call the method from the <code>activity</code> in order to obtain the string, because these method can't be resolved. Can anyone explain me why?</p>
  
  <p>This is the code for the <code>Datepicker</code> that I have in my activity.</p>
  
  <pre><code>public static class DatePickerFragment extends DialogFragment
          implements DatePickerDialog.OnDateSetListener {
      private String date;
      @Override
      public Dialog onCreateDialog(Bundle savedInstanceState) {
          // Use the current date as the default date in the picker
          final Calendar c = Calendar.getInstance();
          int year = c.get(Calendar.YEAR);
          int month = c.get(Calendar.MONTH);
          int day = c.get(Calendar.DAY_OF_MONTH);
  
          // Create a new instance of DatePickerDialog and return it
          return new DatePickerDialog(getActivity(), this, year, month, day);
      }
  
      public void onDateSet(DatePicker view, int year, int month, int day) {
           date=Integer.toString(year)+"-"+Integer.toString(month)+"-"+Integer.toString(day);
      }
  
      public String getDate(){
          return date;
      }
  }
  
  
  public void showDatePickerDialog(View v) {
      DialogFragment newFragment = new DatePickerFragment();
      newFragment.show(getSupportFragmentManager(), "datePicker");
     String date = newFragment.getDate();
  }
  </code></pre>