samedi 7 avril 2018

SQLite + Android : Condition "if" using "&&" statement

i've got a problem when i want to control what i want to insert in my SQLite database.

I use "if" condition and statement "&&" like that :

 if (addDream.isPressed() && lucidbtn.isChecked()) {
        carnet.setText(editDream.getText().toString());
        carnet.setLucid(1);
        cn.insertNoteReve(carnet);
        editDream.setText("");
        xp = exp.xpUp(30);
        user.setExperience(xp);
        userDao.expUp(user);

    }

That work, my xp (here 30) is insert in my database correctly. But when i want to add a second "&&" statement like that :

else if(addDream.isPressed() && lucidbtn.isChecked() && wild.isChecked()) {
        carnet.setText(editDream.getText().toString());
        carnet.setLucid(1);
        cn.insertNoteReve(carnet);
        editDream.setText("");
        xp = exp.xpUp(70);
        user.setExperience(xp);
        userDao.expUp(user);
    }

This doesn't work, that only insert 30 and no 70. I think the problem is with the second "&&" statement because i tried with another condition without "lucidbtn.isChecked" and the value was modified in the database.

How can i fix this problem ?

Aucun commentaire:

Enregistrer un commentaire