Reputation: 239
How do I delete column from table in room database android.I alredy try all the way drop and delete not working.
This code also not working:-
static final Migration MIGRATION_3_4 = new Migration(3, 4)
{
@Override
public void migrate(SupportSQLiteDatabase database)
{
database.execSQL("CREATE TABLE users_new (userid TEXT, username TEXT, last_update INTEGER, PRIMARY KEY(userid))");
// Copy the data
database.execSQL("INSERT INTO users_new (userid, username, last_update) SELECT userid, username, last_update FROM users");
// Remove the old table
database.execSQL("DROP TABLE users");
// Change the table name to the correct one
database.execSQL("ALTER TABLE users_new RENAME TO users");
}
};
Upvotes: 1
Views: 3876
Reputation: 2573
Android ROOM is based on SQL Lite which does not allow dropping database table columns. Instead you have to:
See related question:Sqlite Dropping Column from table
Upvotes: 1