Delete database information

-1
public void excluir (int codigo){

    String[] parametros = new String[1];
    parametros[0] = String.valueOf(codigo);

    conexao.delete("CLIENTE", "CODIGO = ? ", parametros);}

This is the method to delete a data from my table

This is the method called by the onCLick Button /

 public void tirar (View view){
    int x = 1;
    ClienteRepositorio clienteRepositorio = new ClienteRepositorio(conexao);
    clienteRepositorio.excluir(x);
    onResume();

}

This is the class where I create my table (Code is increasing)

public class ScriptDLL {

public static String getCreateTableCliente(){
    StringBuilder sql = new StringBuilder();
    sql.append("   CREATE TABLE IF NOT EXISTS CLIENTE (");
    sql.append("       CODIGO       INTEGER       PRIMARY KEY AUTOINCREMENT NOT NULL,");
    sql.append("       NOME         VARCHAR (250) NOT NULL DEFAULT (''),");
    sql.append("       ENDERECO     VARCHAR (255) NOT NULL DEFAULT (''),");
    sql.append("       EMAIL        VARCHAR (200) NOT NULL DEFAULT (''),");
    sql.append("       TELEFONE     VARCHAR (20)  NOT NULL DEFAULT ('') )");
    return sql.toString();
}

}

This does not work. When I push the button, nothing happens. It does not delete any data from my table. Any suggestions?

    
asked by anonymous 02.04.2018 / 03:47

1 answer

0
import android.database.sqlite.SQLiteDatabase;    

//Onde conn é minha conexão com o sqlite
private SQLiteDatabase conn;

public Repositorio(SQLiteDatabase conn)
{
    this.conn = conn;
}

//chamando o método para realizar o delete
RepositorioColetas.DeletaVenda(adpColeta.getItem(position).getId());

//Método que deleta a venda e itens (no meu caso), passando o id da venda como parâmetro.
public void DeletaVenda(long id)
{
    conn.execSQL("DELETE FROM TBLCTOVENDA where _ID = "+ id);
    conn.execSQL("DELETE FROM TBLCTOITENSVENDA where IDLCTOVENDA = " + id);
}
    
04.04.2018 / 01:23