mark a specific day in a datePicker Android Studio

0

What I want is for the user to select a day in the datePicker and stay selected, as if it were an event, for example. I imagine that this date has to be saved in a bd to load it every time I open my apk, but the problem is: already obtained the dates how to place them in my datePicker. Thanks. I have this, where I take the date that the user chooses, and I save it in a database, the problem is then what I do with the dates so that they are marked in my datePicker.  @Override     public boolean onCreateOptionsMenu (Menu menu) {         getMenuInflater (). inflate (R.menu.options_menu, menu);         return true;     }

public  boolean onOptionsItemSelected(MenuItem item){
    int id = item.getItemId();
    if(id == R.id.MenuOpcion1) {
        showDatePickerDialog();

        return true;
    }
    if(id == R.id.MenuOpcion2) {

        return true;
    }
    return false;

}
private void showDatePickerDialog() {
    DatePickerFragment newFragment = DatePickerFragment.newInstance(new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker datePicker, int year, int month, int day) {
              final String selectedDate = twoDigits(day) + "/" + twoDigits(month+1) + "/" + year;
            //aqui depues lo que biene es guardar esta fecha en la base de datos
        }
    });
    newFragment.show(getSupportFragmentManager(), "datePicker");
}
private String twoDigits(int n) {
    return (n<=9) ? ("0"+n) : String.valueOf(n);
}
    
asked by Oscar Oliva 19.12.2017 в 19:25
source

0 answers