Skip to content Skip to sidebar Skip to footer

Android: Error When Updating Database Using A String

My database contains a list of concerts and I'm updating them based on the name column. When the update button is clicked, the column values of the given concert is passed in. Howe

Solution 1:

value should be quoted:

return db.update(DB_TABLE, updateValues, "name"  + "='" + name +"'", null) > 0

Solution 2:

The Problem in your code is: WHERE name=test

Your query is broken.

Is test a value or a name of a field? Depends on semantic of test you have 3 ways to solve this problem:

  1. If it is a name of a sqlite-field, then your table is missing this field and you should add it to your sqlite-table.

  2. Should be test a value, then you have to use ' around this.

  3. If test is a variable from your java-code, then you have to insert value of this variable into the query with concatenation f.e.

Post a Comment for "Android: Error When Updating Database Using A String"