Update Sqlite with Edittext Android

Asked

Viewed 59 times

0

Good morning gentlemen, I’m trying to update my Sqlite database through my Edittext but it shows error, someone could tell me what I’m missing ?

public void insererazaosocial (SQLiteDatabase db){
        db.execSQL( "UPDATE emitente SET razaosocial='"+selecinfo2.getText().toString()+"' WHERE id = 1");
    }

1 answer

0


I managed to solve the problem, if you want an example you can take my code for you. Strong hug :D

public void insererazaosocial (SQLiteDatabase db){

        String valor = selecinfo2.getText().toString();
        if (valor != null) {
            db.execSQL("UPDATE emitente SET razaosocial='"+valor+"' WHERE id = 1");
            Toast.makeText(getApplicationContext(), "O registro foi gravado no Banco de Dados", Toast.LENGTH_SHORT).show();
        }
        else{
            Toast.makeText(getApplicationContext(), "Verifique as informações e tente novamente", Toast.LENGTH_SHORT).show();
        }
    }

Browser other questions tagged

You are not signed in. Login or sign up in order to post.