H2OpenHelper
This helper class helps creating and managing databases. A subclass typically
implements the "on" methods.
| Methods |
|
H2OpenHelper(Context context, String name, H2Database.CursorFactory factory, int version)
Construct a new instance.
|
|
H2OpenHelper(Context context, String name, H2Database.CursorFactory factory, int version)
Construct a new instance.
Parameters:
context - the context to use
name - the name of the database (use null for an in-memory database)
factory - the cursor factory to use
version - the expected database version
|
| void |
close()
Close the connection.
|
| void |
close()
Close the connection.
|
| H2Database |
getReadableDatabase()
Open a read-only connection.
|
| H2Database |
getReadableDatabase()
Open a read-only connection.
Returns:
a new read-only connection
|
| H2Database |
getWritableDatabase()
Open a read-write connection.
|
| H2Database |
getWritableDatabase()
Open a read-write connection.
Returns:
a new read-write connection
|
| void |
onCreate(H2Database db)
This method is called when the database did not already exist.
|
| void |
onCreate(H2Database db)
This method is called when the database did not already exist.
Parameters:
db - the connection
|
| void |
onOpen(H2Database db)
This method is called after opening the database.
|
| void |
onOpen(H2Database db)
This method is called after opening the database.
Parameters:
db - the connection
|
| void |
onUpgrade(H2Database db, int oldVersion, int newVersion)
This method is called when the version stored in the database file does
not match the expected value.
|
| void |
onUpgrade(H2Database db, int oldVersion, int newVersion)
This method is called when the version stored in the database file does
not match the expected value.
Parameters:
db - the connection
oldVersion - the current version
newVersion - the expected version
|
|