public class DatabaseSource extends android.database.sqlite.SQLiteOpenHelper implements DatabaseProvider<android.database.sqlite.SQLiteDatabase>
Connection wrapping
the standard java SQLite API turning it into standard JDBC APIs.
This class extends the standard SQLiteOpenHelper and is used to create the database.
onCreate(SQLiteDatabase) will create the database tables & columns automatically.
onUpgrade(SQLiteDatabase, int, int) will create any missing tables/columns, however
it will not remove any tables/columns more complex upgrades should be handled by overriding
onUpgrade(SQLiteDatabase, int, int) and implementing a script to handle the migration.
| Constructor and Description |
|---|
DatabaseSource(android.content.Context context,
io.requery.meta.EntityModel model,
int version)
Creates a new
DatabaseSource instance. |
DatabaseSource(android.content.Context context,
io.requery.meta.EntityModel model,
java.lang.String name,
int version)
Creates a new
DatabaseSource instance. |
DatabaseSource(android.content.Context context,
io.requery.meta.EntityModel model,
java.lang.String name,
android.database.sqlite.SQLiteDatabase.CursorFactory factory,
int version)
Creates a new
DatabaseSource instance. |
DatabaseSource(android.content.Context context,
io.requery.meta.EntityModel model,
java.lang.String name,
android.database.sqlite.SQLiteDatabase.CursorFactory factory,
int version,
io.requery.sql.platform.SQLite platform)
Creates a new
DatabaseSource instance. |
| Modifier and Type | Method and Description |
|---|---|
io.requery.sql.Configuration |
getConfiguration() |
java.sql.Connection |
getConnection() |
protected void |
onConfigure(io.requery.sql.ConfigurationBuilder builder)
Override to modify the configuration before it is built.
|
void |
onConfigure(android.database.sqlite.SQLiteDatabase db)
Callback for when the database should be configured.
|
void |
onCreate(android.database.sqlite.SQLiteDatabase db)
Callback for when the database schema is to be created.
|
protected io.requery.sql.Mapping |
onCreateMapping(io.requery.sql.Platform platform)
Override to change the default
Mapping. |
void |
onUpgrade(android.database.sqlite.SQLiteDatabase db,
int oldVersion,
int newVersion)
Callback for when the database should be upgraded from an previous version to a new version.
|
void |
setLoggingEnabled(boolean enable)
Enables statement logging.
|
void |
setTableCreationMode(io.requery.sql.TableCreationMode mode)
Sets the
TableCreationMode to use when the database is created or upgraded. |
close, getDatabaseName, getReadableDatabase, getWritableDatabase, onDowngrade, onOpen, setWriteAheadLoggingEnabledclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitclose, getReadableDatabase, getWritableDatabasepublic DatabaseSource(android.content.Context context,
io.requery.meta.EntityModel model,
int version)
DatabaseSource instance.context - contextmodel - the entity modelversion - the schema versionpublic DatabaseSource(android.content.Context context,
io.requery.meta.EntityModel model,
@Nullable
java.lang.String name,
int version)
DatabaseSource instance.context - contextmodel - the entity modelname - database filenameversion - the schema versionpublic DatabaseSource(android.content.Context context,
io.requery.meta.EntityModel model,
@Nullable
java.lang.String name,
@Nullable
android.database.sqlite.SQLiteDatabase.CursorFactory factory,
int version)
DatabaseSource instance.context - contextmodel - the entity modelname - database filenamefactory - optional SQLiteDatabase.CursorFactoryversion - the schema versionpublic DatabaseSource(android.content.Context context,
io.requery.meta.EntityModel model,
@Nullable
java.lang.String name,
@Nullable
android.database.sqlite.SQLiteDatabase.CursorFactory factory,
int version,
io.requery.sql.platform.SQLite platform)
DatabaseSource instance.context - contextmodel - the entity modelname - database filenamefactory - optional SQLiteDatabase.CursorFactoryversion - the schema versionplatform - platform instancepublic void setLoggingEnabled(boolean enable)
DatabaseProvidersetLoggingEnabled in interface DatabaseProvider<android.database.sqlite.SQLiteDatabase>enable - true to enable, false otherwise default is false.public void setTableCreationMode(io.requery.sql.TableCreationMode mode)
DatabaseProviderTableCreationMode to use when the database is created or upgraded.setTableCreationMode in interface DatabaseProvider<android.database.sqlite.SQLiteDatabase>mode - to useprotected io.requery.sql.Mapping onCreateMapping(io.requery.sql.Platform platform)
Mapping.platform - platform instanceprotected void onConfigure(io.requery.sql.ConfigurationBuilder builder)
builder - instance to configure.public io.requery.sql.Configuration getConfiguration()
getConfiguration in interface DatabaseProvider<android.database.sqlite.SQLiteDatabase>Configuration used by the providerpublic void onCreate(android.database.sqlite.SQLiteDatabase db)
DatabaseProvideronCreate in interface DatabaseProvider<android.database.sqlite.SQLiteDatabase>onCreate in class android.database.sqlite.SQLiteOpenHelperdb - instancepublic void onConfigure(android.database.sqlite.SQLiteDatabase db)
DatabaseProvideronConfigure in interface DatabaseProvider<android.database.sqlite.SQLiteDatabase>onConfigure in class android.database.sqlite.SQLiteOpenHelperdb - instancepublic void onUpgrade(android.database.sqlite.SQLiteDatabase db,
int oldVersion,
int newVersion)
DatabaseProvideronUpgrade in interface DatabaseProvider<android.database.sqlite.SQLiteDatabase>onUpgrade in class android.database.sqlite.SQLiteOpenHelperdb - instancepublic java.sql.Connection getConnection()
throws java.sql.SQLException
getConnection in interface io.requery.sql.ConnectionProviderjava.sql.SQLException