I want to know .
I have one Table
create table User (userid INTEGER PRIMARY KEY AUTOINCREMENT, username text,address text)
and i am creating this table on onCreate()
and inserting the value.
INSERT into User (username,address) VALUES('noname','xyz')
output-username--noname address--xyz
and on onUpgrade()
i added one column in above table
ALTER TABLE User ADD COLUMN City text
and insert value INSERT into User(City) VALUES('delhi')
when i launch the app the output its showing.
output- username--null address--null city--delhi
why its showing null
for both column .even i did not drop
the table
it should show something like this
output- username--noname address--xyz city--delhi
please clarify this behavior of onUpgrade
like this:-
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
{
db.execSQL("ALTER TABLE User ADD COLUMN City TEXT");
db.execSQL("INSERT into User (City) VALUES(delhi)");
}