0
Error when saving the image path in SQLITE. Says it does not have a column named pathImage in the products table attached to the image with the error for better understanding.
My Dao Product Class:
import android.content.ContentValues;
import android.database.Cursor;
import br.gestaoBd.Beans.Produto;
import br.gestaoBd.Login;
import java.util.ArrayList;
public class ProdutoDao {
public void inserirProduto(Produto produto) {
System.out.println("Inserindo produto...");
ContentValues v = new ContentValues();
v.put("descricao", produto.getDescricao());
v.put("precoDeCusto", produto.getPrecoDeCusto());
v.put("percDeLucro", produto.getPercDeLucro());
v.put("precoDeVenda", produto.getPrecoDeVenda());
v.put("pathImagem", produto.getPathImagem());
Login.db.insert("produtos", null, v);
//ProjetoBd.db.close();
System.out.println("Inseriu...");
}
public static void alterar(Produto produto) {
ContentValues cv = new ContentValues();
cv.put("descricao", produto.getDescricao());
cv.put("precoDeCusto", produto.getPrecoDeCusto());
cv.put("percDeLucro", produto.getPercDeLucro());
cv.put("precoDeVenda", produto.getPrecoDeVenda());
cv.put("pathImagem", produto.getPathImagem());
.........
Bank structure
........
sb = new StringBuilder();
sb.append(" CREATE TABLE IF NOT EXISTS [produtos] (");
sb.append(" [id] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,");
sb.append(" [descricao] VARCHAR2(50) NOT NULL,");
sb.append(" [precoDeCusto] DOUBLE NOT NULL,");
sb.append(" [percDeLucro] DOUBLE NOT NULL,");
sb.append(" [precoDeVenda] DOUBLE NOT NULL,");
sb.append(" [pathImagem] VARCHAR2(125) NOT NULL)");
.........

The image cuts out the most important part of the error. Put it as text itself. Only the header suffices. It seems to be all in order, but the
INSERTis a little weird, I don’t know if it’s something from the Android ORM. Have you tried to list the bank structure to make sure the column is there?– Maniero
@ bigown ERROR: Sqlitedatabase android.database.sqlite.SQLiteException: table produtos has no column named pathImagem (code 1): , while compiling: INSERT INTO produtos(percDeLucro,descricao,pathImagem,precoDeVenda,precoDeCusto) VALUES (?,?,?,?,?)
– Eduardo Krakhecke
Check the creation of the database, if the columns are being created correctly.
– user28595
I’ve already done it. As far as I can tell, they’re properly created.
– Eduardo Krakhecke