1
So my problem is this one, I’ve tried and researched everything but I couldn’t implement any solution. I tried to update the database with the update and also insert new columns with ALTER TABLE, nothing worked. I am a beginner so please be very specific with the answers. Thank you.
Nome has no column named bairro (code 1): ,while compiling:
INSERT INTO Nome(email,bairro,rua,nomeDoCliente,telefoneResidencial,celular) VALUES (?,?,?,?,?,?)
//Create da classe Helper
db.execSQL("CREATE TABLE "
+ ClientesDAO.TABLE_NAME
+ " (" + ClientesDAO.ID
+ " INTEGER PRIMARY KEY,"
+ ClientesDAO.NOME_CLIENTE + " TEXT,"
+ ClientesDAO.RUA + " TEXT,"
+ ClientesDAO.EMAIL + " TEXT,"
+ ClientesDAO.BAIRRO + " TEXT,"
+ ClientesDAO.TELEFONE + " TEXT,"
+ ClientesDAO.CELULAR + " TEXT);"
);
//insert da classe ClientesDAO
public void insert(Clientes clientes){
ContentValues cv = new ContentValues();
cv.put(NOME_CLIENTE, clientes.getNome());
cv.put(RUA, clientes.getRua());
cv.put(BAIRRO, clientes.getBairro());
cv.put(EMAIL, clientes.getEmail());
cv.put(TELEFONE, clientes.getTelefone());
cv.put(CELULAR, clientes.getCelular());
db.getWritableDatabase().insert(TABLE_NAME, null, cv);
}
//Método setado no onClick da minha tela de cadastros
public void gravarNoBanco(){
cd.insert(new Clientes(0, edit_nome.getText().toString(),edit_rua.getText().toString(),edit_email.getText().toString(),edit_bairro.getText().toString(),edit_telefone.getText().toString(),edit_celular.getText().toString()));
clear();
}
Whenever you change the database you have to uninstall the application or increase its version in the class it inherits from Sqliteopenhelper
– ramaral
That was the end of it.obg.
– Cesar Roberto Martins