2
Autoincrement is not working on my Sqlite tables.
Table:
db.execSQL("create table usuario(_idUsuario integer primary key autoincrement, nome text not null, email text not null, senha text not null)");
Insert:
public String insertUsuario(Usuario usuario) {
db = dbHelper.getWritableDatabase();
long resultado;
ContentValues values = new ContentValues();
values.put("nome", usuario.getNome());
values.put("email", usuario.getEmail());
values.put("senha", usuario.getSenha());
resultado = db.insert("usuario", null, values);
if (resultado == -1) {
return "Usuário não foi criado!";
} else {
return "Usuário foi criado com sucesso";
}
}
I enter the values through the code below:
usuario.setNome(cadNome);
usuario.setEmail(cadEmail);
usuario.setSenha(cadSenha);
DBControle db = new DBControle(getApplicationContext());
String a = db.insertUsuario(usuario);
Any user that is created is with id = 0. What I am doing wrong?
can you show how you get these values? Thank you very much
– Thiago Luiz Domacoski
I have attached the question.
– Christian Gomes da Silva
Sorry, how does the SELECT, and brings the id = 0.
– Thiago Luiz Domacoski
Thiago, I think I got thank you for your attention.
– Christian Gomes da Silva
Ok! feel free to answer your question, so you can help another user, who has the same question!
– Thiago Luiz Domacoski
Okay thanks so much for the advice!
– Christian Gomes da Silva