public abstract class RdbOpenCallback extends Object
You can create a child class to implement the #onCreate, #onUpgrade, or #onOpen method.
If a database already exists, it will be opened; if no database exists, a database will be created.
During database upgrade, the methods of this class are also called.
SystemCapability.Data#DATA_APPDATAMGR| 构造器 | 说明 |
|---|---|
RdbOpenCallback() |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
onCorruption(File databaseFile) |
Called when a corruption exception occurs when the database is opened.
|
abstract void |
onCreate(RdbStore store) |
Called when the database associated with an RDB store is created.
|
void |
onDowngrade(RdbStore store,
int currentVersion,
int targetVersion) |
Called when the database associated with this RdbStore needs to be downgraded.
|
void |
onOpen(RdbStore store) |
Called when the database associated with an RDB store is opened.
|
abstract void |
onUpgrade(RdbStore store,
int currentVersion,
int targetVersion) |
Called when the database associated with an RDB store needs to be upgraded.
|
public abstract void onCreate(RdbStore store)
This method creates a database and inserts initialized table data into the database.
store - Indicates the RdbStore object.public abstract void onUpgrade(RdbStore store, int currentVersion, int targetVersion)
This method is executed in a transaction. If an exception is thrown, all changes will be automatically rolled back.
store - Indicates the RdbStore object.currentVersion - Indicates the current database version.targetVersion - Indicates the target database version.public void onDowngrade(RdbStore store, int currentVersion, int targetVersion)
This method is executed in a transaction. If an exception is thrown, all changes will be automatically rolled back.
store - Indicates the RdbStore object.currentVersion - Indicates the current database version.targetVersion - Indicates the target database version.public void onOpen(RdbStore store)
store - Indicates the RdbStore object.public void onCorruption(File databaseFile)
databaseFile - the file representing the database on which corruption
is detected.