public interface CreateAndUpgrade
| Modifier and Type | Method and Description |
|---|---|
void |
onCreate()
Called when the database is created for the first time.
|
void |
onUpgrade(int oldVersion,
int newVersion)
Called when the database needs to be upgraded.
|
void onCreate()
void onUpgrade(int oldVersion,
int newVersion)
If you add new columns you can use ALTER TABLE to insert them into a live table. If you rename or remove columns you can use ALTER TABLE to rename the old table, then create the new table and then populate the new table with the contents of the old table.
This method executes within a transaction. If an exception is thrown, all changes will automatically be rolled back.
oldVersion - The old database version.newVersion - The new database version.Copyright © 2025. All rights reserved.