My SQLite database is missing a column which I know exists. I will not be able to pull the database from the Android Emulator, because there is no way to populate it with the emulator without substantial code rewrite.
logcat returns sqlite returned: error code = 1, msg = table items has no column named checkedout when I add an item to this table. Below is the table declaration, and below that is the insert function. Do I spell checkedout inconsistently somewhere?
static final String CREATE_ITEM_TABLE ="create table if not exists "+CHECKOUT_TABLE+" ("
+ KEY_ROWID + " INTEGER PRIMARY KEY,"
+ KEY_STORE +" TEXT,"
+ KEY_INVID + " TEXT,"
+ KEY_PRODUCT + " TEXT,"
+ KEY_PRICE + " TEXT,"
+ KEY_WEIGHT + " TEXT,"
+ KEY_CATEGORY + " TEXT,"
+ KEY_QUANTITY + " TEXT,"
+ KEY_CHECKEDOUT + "INTEGER"
+ ");";
//store item
public long storeNewItem(String store, String invid, String product,
String price, String weight, String category, String quantity, int checkedout) {
ContentValues initialValues = new ContentValues();
initialValues.put(KEY_STORE, store);
initialValues.put(KEY_INVID, invid);
initialValues.put(KEY_PRODUCT, product);
initialValues.put(KEY_WEIGHT, price);
initialValues.put(KEY_CATEGORY, weight);
initialValues.put(KEY_QUANTITY, quantity);
initialValues.put(KEY_CHECKEDOUT, checkedout); //just in case I want to store these items, but server should know
if(checkedout==0)
{
return sqlDb.insert(CHECKOUT_TABLE, null, initialValues);
}
else //if checkedout==true
{
return sqlDb.insert(PAST_ITEM_TABLE, null, initialValues);
}
}
the answer was that the last column did not have a space in the declaration
+ KEY_QUANTITY + " TEXT,"
+ KEY_CHECKEDOUT + "INTEGER"
+ ");";
should have been
+ KEY_QUANTITY + " TEXT,"+ KEY_CHECKEDOUT + " INTEGER"
+ ");";
sigh