In my Android application I'm using the SQLite DB with SQLiteOpenHelper
I have several DB versions, and I've been doing onUpgrade() operations by switching on the old db version, but now I have to remove one of the tables because I'm no longer using it, so should I do something different?
public void onCreate(SQLiteDatabase database) {
database.execSQL(tableUserCreate);
database.execSQL(tableProductsCreate);
database.execSQL(tablePicturesCreate);
}
public void onUpgrade(SQLiteDatabase database, int version_old, int current_version) {
switch (version_old) {
case 1:
database.execSQL(addPostcodeFieldToUserTable);
database.execSQL(tablePlacesCreate);
// Intentional fallthrough, no break;
case 2:
database.execSQL(tableProductVideosCreate);
break;
}
} // End of onUpgrade
Now I want to remove the User table in a new DB version. What do I do?
SQL for dropping a table:
DROP TABLE table_name
Or use:
DROP TABLE IF EXISTS table_name
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With