sqlite - android insists i don't have a column in my database table -


i can't figure out strange error while try insert value database

error

01-01 15:48:56.065  10056-10056/com.autophone e/sqlitelog﹕ (1) table maintable has no column named status_date 01-01 15:48:56.100  10056-10056/com.autophone e/sqlitedatabase﹕ error inserting status_date=1 בינו 2000 15:48:56 problem=non model=n9005 phone_number=123 in_date=1 בינו 2000 15:48:56 status=received name=ian     android.database.sqlite.sqliteexception: table maintable has no column named status_date (code 1): , while compiling: insert maintable(status_date,problem,model,phone_number,in_date,status,name) values (?,?,?,?,?,?,?) 

the main point says don't have "status_date" in main table how possible?

  public static final string key_rowid = "_id";     public static final int col_rowid = 0;      private static final string key_name = "name";//1     private static final string key_model = "model";//2     private static final string key_phone_number = "phone_number";//3     private static final string key_problem = "problem";//4     private static final string key_status = "status";//5     private static final string key_in_date = "in_date";//6     private static final string key_status_date = "status_date";//7      public static final string database_name = "mydb";     public static final string database_table = "maintable";     public static final int database_version = 1;      private static final string database_create_sql =             "create table " + database_table                     + " (" + key_rowid + " integer primary key autoincrement, "                     + key_name + " text not null, "                     + key_model + " text not null, "                     + key_phone_number + " text not null, "                     + key_problem + "text not null, "                     + key_status + "text not null, "                     + key_in_date + "text not null, "                     + key_status_date + "text not null "                     +");"; 

here is...

this enter part

 long newid=mydb.insertrow(new logentery("ian","n9005","123","non")); 

logentery class use adds rest data

public logentery(string name,string model,string phone_number,string problem)     {         super();         this.name=name;         this.model=model;         this.phone_number=phone_number;         this.problem=problem;         this.in_date = dateformat.getdatetimeinstance().format(new date());         this.status_date = dateformat.getdatetimeinstance().format(new date());         this.status = "received";     } 

by way... how change getdatetimeinstance dd/mm/yyyy , not full data/time?

a common source of error database version.

if ran app @ least once without key_status_date field in table, , added field , ran app, table won't updated (onupgrade() not called), because system thinks database hasn't changed.

try raising version.

public static final int database_version = 2;  

with this, system think "oh, there's new version of database, let's call onupgrade()". ideally method, delete tables call oncreate(sqlitedatabase db) manually, or execute ddl statements add missing field.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -