cannot get back the date selected from DatePicker
<p>I am trying to get back the date selected in the DatePicker which is shown in a dialog. I mean I have a ActionBarSherlock with a menu which when pressed opens a dialog which has a datepicker and a EditItem.Now when I select a date and the amount I want to get those parameters.but I get error.Can somebody please help me. I have copied my code below</p>

<pre><code>@Override
public boolean onCreateOptionsMenu(Menu menu) {
    menu.add("Add Detail").setIcon(R.drawable.ic_compose).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);

    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    final Dialog dialog = new Dialog(this);
    dialog.setContentView(R.layout.custom);

    Button cancelButton = (Button) dialog.findViewById(R.id.canelButton);
    final DatePicker datePicker = (DatePicker) findViewById(R.id.datePicker1);

    Button OKButton = (Button) dialog.findViewById(R.id.OKbutton);

    OKButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Log.d("---------------",datePicker.getDayOfMonth()+" ");
        }
    });

    // if button is clicked, close the custom dialog
    cancelButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });

    dialog.show();

    return true;
}
</code></pre>
