My Android app is based on a date picker, where every time the date is changed a database call is made. However, I would like that whenever the application is started, it is considered that the current date has been pressed. How could I do that? Is there a component that allows me to do it?
The code I use to initialize the datePicker is as follows:
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH);
int day = c.get(Calendar.DAY_OF_MONTH);
calendario.init(year, month, day, new DatePicker.OnDateChangedListener({//codigo para conectar a la base de datos});
A solution would be to implement
DatePicker.OnDateChangedListener
in the class usingimplements
:Once that's done I would implement the method as usual:
Finally you can indicate this method to your call to
calendario.init
and call it immediately after so that it executes it with the data that you just loaded into it:Code used to reproduce the problem: