android - SQLite is not deleting rows -
i have table in database, created 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 program, want this:
private void deleteexpediente(long codficha) { cursor cursorborra=db.rawquery("delete fichas codficha='"+codficha+"'", null); dbhelper.copiardb(); }
but, way, none row affected. have checked codficha exists, database not null, etc. no exception thrown, simply...row not deleted. copiardb() method copy database location in device (is not rooted, cannot see database) , there check row has not been deleted.
any idea why cannot delete row? thank you.
db.delete("fitcas", "codficha = ?", new string[] { integer.tostring(codficha) });
a rawquery returns cursor of result set, reference query results. should using straight delete() call. take @ documentation:
http://developer.android.com/reference/android/database/sqlite/sqlitedatabase.html
or sqlitestatement:
http://developer.android.com/reference/android/database/sqlite/sqlitestatement.html
Comments
Post a Comment