dimanche 13 septembre 2015

Validation for save button

i've difficulty in creating a validation before saving it to sqlite, below is the code:

public void save(View v){
        String weight = weightinputid.getText().toString();
        String bmi = BMIfinal.getText().toString();
        String status = BMIStatus.getText().toString();


        long id = data.insertData(weight, bmi, status);

        if(id<0){
            message.mess(this, "Error");
        }

        else{
            message.mess(this, "BMI has been saved");
        }
    }

how do i create a validation if all the textfields are empty? my problem right now, even if i pressed the save button, the empty textfields was saved inside the database

Aucun commentaire:

Enregistrer un commentaire