Help w/ DatePicker Android Dev

+1 Frrancesc Rodriguez · April 3, 2015
Hello Guys, 

I'm Interested in learning how to create Time and Date Picker with dialog, By dialog i mean the  date and time communicates with the program by saving the preferred date, 

For instance, let's say 

  • I weight 140 pounds 2 weeks ago and i want to go back two weeks ago and store the data 

  • I want to calculate how much i weighted 2 weeks ago with my weight today so basically subtracting the weight. 

I've watched Bucky's tutorial and he's information is very useful but he hasn't covered DatePicker. 
This is the code I have for Date Picker i just really need help with storing the data and making a log out of it. 

Any help is highly appreciated! 
public class MainActivity extends ActionBarActivity {
    static final int dialog_id = 0;
    int hour, minute;

    protected void onCreate(Bundle savedInstanceState) {

    protected Dialog onCreateDialog(int id)
        switch (id)

            case dialog_id:

                return new TimePickerDialog(this, mTimeSetListerner, hour, minute, false);

        return null;

    protected TimePickerDialog.OnTimeSetListener mTimeSetListerner = new TimePickerDialog.OnTimeSetListener() {

        public void onTimeSet(TimePicker view, int hourOfDay, int hour_minute) {
            hour = hourOfDay;
            minute = hour_minute;

            Toast.makeText(getBaseContext(), " Setted Time: " + hour + ": " + minute, Toast.LENGTH_LONG).show();



Post a Reply


Oldest  Newest  Rating
0 Bartosz Macięga · April 3, 2015
I think for storage data the best will be SQL database, look at this docs there is explained everything :)

Hope it helps :)
  • 1

Java / Android Development


Very popular language used to create desktop applications, website applets, and Android apps.

Bucky Roberts Administrator