INSERT INTO android SQL statment trouble -


i having trouble directly inserting data sqlite using insert statment, silly mistake cannot find it.

    string sql = ("insert task(task_goal) values('asda');");             this.ourdatabase.execsql(sql);  

error is:

   table task has no column named task_goal 

there column named task goal, im not sure why error occuring?

db.execsql("create table " + database_task3 + " (" +              key_rowid + " integer primary key autoincrement, " +             key_goal + " text not null);"            ); 

where:

public static final string key_rowid = "_id"; public static final string key_goal = "task_goal"; private static final string database_task3 = "task"; 

it appears have changed java code defines table after running app @ least once, haven't updated sql schema. need increment database_version tell sqliteopenhelper there new schema, not check you.


database_version common variable passed sqliteopenhelper constructor, not universal, if don't use variable need increment whatever value pass sqliteopenhelper constructor:

sqliteopenhelper (context context, string name,          sqlitedatabase.cursorfactory factory, int version) 

Comments