lundi 27 juillet 2015

SQLite is not deleting rows

I have a table in my database, that is created this way:

private static String crea_Fichas="CREATE TABLE fichas ("+
        "provincia VARCHAR (40), "+
        "municipio VARCHAR (40), "+
        "distrito VARCHAR (40), "+
        "codficha INTEGER, "+
        "codagente INTEGER, "+
        "domitri VARCHAR(80), "+
        "domfiscal VARCHAR(80), "+
        "CIERNC VARCHAR(13), "+
        "nombrecompleto VARCHAR (255), "+
        "telf1 VARCHAR(12), "+
        "telf2 VARCHAR(12), "+
        "fax VARCHAR(12), "+
        "razonsocial VARCHAR(255), "+
        "nombrecomercial VARCHAR(255), "+
        "email VARCHAR(50), "+
        "codexpediente INTEGER, "+
        "croquis BYTEA, "+
        "codtipoactividad INTEGER, "+
        "primary key(codficha), "+
        "foreign key (codtipoactividad) references tiposactividades(codtipoactividad), " +
        "foreign key (codexpediente) references expedientes (codexpediente), "+
        "foreign key (codagente) references agentes(codagente));";

Later in my program, I want to do this:

private void deleteExpediente(long codficha) {

    Cursor cursorBorra=db.rawQuery("DELETE FROM fichas where codficha='"+codficha+"'", null);
    dbHelper.copiarDb();

}

but, this way, none row is affected. I have checked that codficha exists, database is not null, etc. No Exception is thrown, simply...row is not deleted. copiarDb() is a method to copy my database to another location in my device (is not rooted, so I cannot see the database) and is there where I check the row has not been deleted.

Any idea why I cannot delete that row? Thank you.

Aucun commentaire:

Enregistrer un commentaire