when i try to update a table the app crashing and return this fatal error:
06-09 08:02:34.026: I/Database(342): sqlite returned: error code = 1, msg = no such column: username
06-09 08:02:34.034: E/Database(342): Error updating valore=1234 using UPDATE parametri SET valore=? WHERE _parametro=username
06-09 08:02:34.034: D/AndroidRuntime(342): Shutting down VM
06-09 08:02:34.034: W/dalvikvm(342): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
06-09 08:02:34.054: E/AndroidRuntime(342): FATAL EXCEPTION: main
06-09 08:02:34.054: E/AndroidRuntime(342): android.database.sqlite.SQLiteException: no such column: username: , while compiling: UPDATE parametri SET valore=? WHERE _parametro=username
The function of insert/update is this:
String strFilter = ParametriMetaData.PARAMETRO+"=" + parametro;
ContentValues args = new ContentValues();
args.put(ParametriMetaData.VALORE, valore);
System.out.println( strFilter );
mDb.update(ParametriMetaData.TAB_PARAMETRI, args, strFilter, null);
This is the definition of table:
private static final String CREA_TAB_PARAMETRI = "CREATE TABLE IF NOT EXISTS " //codice sql di creazione della tabella
+ ParametriMetaData.TAB_PARAMETRI + " ("
+ ParametriMetaData.PARAMETRO+ " text primary key, "
+ ParametriMetaData.VALORE + " text not null);";
Whatsup? Thank you!
Update query must have proper where clause
update(tablename, value, referenceField+"=?", value);