I have made an android program which is database program. It only has to fetch data from EditText and store it into SQLite database. But, problem is this that it fails to store data and gives up an error which one can only see in LOGCAT when program is running. Here is my code of DBHelper which helps in creating table:
public class DbHelper extends SQLiteOpenHelper {
static String DATABASE_NAME = "userdata";
public static final String TABLE_NAME = "user";
public static final String KEY_FNAME = "fname";
public static final String KEY_LNAME = "lname";
public static final String KEY_PSIZE = "psize";
public static final String KEY_PPRICE = "pprice";
public static final String KEY_ID = "id";
public DbHelper(Context context) {
super(context, DATABASE_NAME, null, 2);
}
@Override
public void onCreate(SQLiteDatabase db) {
String CREATE_TABLE = "CREATE TABLE "
+ TABLE_NAME + "("
+ KEY_ID + " INTEGER PRIMARY KEY, "
+ KEY_FNAME + " TEXT, "
+ KEY_LNAME + " TEXT, "
+ KEY_PSIZE + " NUMBER, "
+ KEY_PPRICE + " NUMBER);";
db.execSQL(CREATE_TABLE);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
onCreate(db);
}}
This code does not display the database data in activity(where it is suppose to) but gives error as:
"table user has no column named psize (code 1)"
I am sure problem exists here but i am unable to find out.