java - SQLiteException no such column (code 1)? -


i keep getting error:

sqliteexception: no such column: name (code 1): , while compiling: select _id, date, amount, item items_table order name

every time try entering activity, crashes , i'm not sure how go fixing it. i've tried many options suggested other users in forum no avail. appreciated.

this logcat:

it seems pointing towards activity called "t_entertainment"

here t_entertainment.class

prefs = preferencemanager.getdefaultsharedpreferences(this);     initlist();     prefs.registeronsharedpreferencechangelistener(preflistener);      //newentry = (button) findviewbyid(r.id.add_entry);     //newentry.setonclicklistener(new view.onclicklistener() {      //@override     //public void onclick(view v) {     //startactivity(new intent(t_entertainment.this, newentry.class));     //} } //}  private void initlist(){     if (model != null){         stopmanagingcursor(model);         model.close();     }     model = helper.getall(prefs.getstring("sort_order", "name"));     startmanagingcursor(model);     adapter = new itemadapter(model);     setlistadapter(adapter); } 

and here helper.class

class helper extends sqliteopenhelper { private static final string database_name = "mymanager.db"; private static final int schema_version = 2;  public helper(context context) {     super(context, database_name, null, schema_version); }  @override public void oncreate(sqlitedatabase db) {     // called once when database not created     db.execsql("create table items_table (_id integer primary key autoincrement, "             + "date text, amount text, item text);"); }  @override public void onupgrade(sqlitedatabase db, int oldversion, int newversion) {     //will not called until 2nd scheme i.e. when scheme_version     //increases  }  /*read records items_table */ public cursor getall(string orderby) {     return (getreadabledatabase().rawquery (             "select _id, date, amount, item items_table order " + orderby, null)); }  /* read record items_table id provided */ public cursor getbyid(string id) {     string[] args = { id };      return (getreadabledatabase().rawquery("select _id, date, amount, item items_table _id=?", args)); }  /* write record items_table */ public void insert(string date, string amount, string item) {     contentvalues cv = new contentvalues();      cv.put("date", date);     cv.put("amount", amount);     cv.put("item", item);      getwritabledatabase().insert("items_table", "name", cv); }  public void update(string id, string date, string amount, string item) {     contentvalues cv = new contentvalues();     string[] args = { id };     cv.put("date", date);     cv.put("amount", amount);     cv.put("item", item);      getwritabledatabase().update("items_table", cv, "_id=?", args); }  public string getid(cursor c) {     return (c.getstring(0)); }  public string getdate(cursor c) {     return (c.getstring(1)); }  public string getamount(cursor c) {     return (c.getstring(2)); }  public string getitem(cursor c) {     return (c.getstring(3)); }  } 

seems updating database previous version new have added 1 column. try delete old application device , install again, shouldn't issue anymore.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -