public abstract class OrmLiteSqliteOpenHelper
extends android.database.sqlite.SQLiteOpenHelper
Modifier and Type | Field and Description |
---|---|
protected boolean |
cancelQueriesEnabled |
protected AndroidConnectionSource |
connectionSource |
protected static com.j256.ormlite.logger.Logger |
logger |
Constructor and Description |
---|
OrmLiteSqliteOpenHelper(android.content.Context context,
String databaseName,
android.database.sqlite.SQLiteDatabase.CursorFactory factory,
int databaseVersion) |
OrmLiteSqliteOpenHelper(android.content.Context context,
String databaseName,
android.database.sqlite.SQLiteDatabase.CursorFactory factory,
int databaseVersion,
android.database.DatabaseErrorHandler errorHandler) |
OrmLiteSqliteOpenHelper(android.content.Context context,
String databaseName,
android.database.sqlite.SQLiteDatabase.CursorFactory factory,
int databaseVersion,
File configFile)
Same as the other constructor with the addition of a config-file.
|
OrmLiteSqliteOpenHelper(android.content.Context context,
String databaseName,
android.database.sqlite.SQLiteDatabase.CursorFactory factory,
int databaseVersion,
InputStream stream)
Same as the other constructor with the addition of a input stream to the table config-file.
|
OrmLiteSqliteOpenHelper(android.content.Context context,
String databaseName,
android.database.sqlite.SQLiteDatabase.CursorFactory factory,
int databaseVersion,
int configFileId)
Same as the other constructor with the addition of a file-id of the table config-file.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close any open connections.
|
com.j256.ormlite.support.ConnectionSource |
getConnectionSource()
Get the connection source associated with the helper.
|
<D extends com.j256.ormlite.dao.Dao<T,?>,T> |
getDao(Class<T> clazz)
Get a DAO for our class.
|
<D extends com.j256.ormlite.dao.RuntimeExceptionDao<T,?>,T> |
getRuntimeExceptionDao(Class<T> clazz)
Get a RuntimeExceptionDao for our class.
|
boolean |
isOpen()
Return true if the helper is still open.
|
void |
onCreate(android.database.sqlite.SQLiteDatabase db)
Satisfies the
SQLiteOpenHelper.onCreate(SQLiteDatabase) interface method. |
abstract void |
onCreate(android.database.sqlite.SQLiteDatabase database,
com.j256.ormlite.support.ConnectionSource connectionSource)
What to do when your database needs to be created.
|
abstract void |
onUpgrade(android.database.sqlite.SQLiteDatabase database,
com.j256.ormlite.support.ConnectionSource connectionSource,
int oldVersion,
int newVersion)
What to do when your database needs to be updated.
|
void |
onUpgrade(android.database.sqlite.SQLiteDatabase db,
int oldVersion,
int newVersion)
Satisfies the
SQLiteOpenHelper.onUpgrade(SQLiteDatabase, int, int) interface method. |
String |
toString() |
protected static com.j256.ormlite.logger.Logger logger
protected AndroidConnectionSource connectionSource
protected boolean cancelQueriesEnabled
public OrmLiteSqliteOpenHelper(android.content.Context context, String databaseName, android.database.sqlite.SQLiteDatabase.CursorFactory factory, int databaseVersion)
context
- Associated content from the application. This is needed to locate the database.databaseName
- Name of the database we are opening.factory
- Cursor factory or null if none.databaseVersion
- Version of the database we are opening. This causes onUpgrade(SQLiteDatabase, int, int)
to be
called if the stored database is a different version.public OrmLiteSqliteOpenHelper(android.content.Context context, String databaseName, android.database.sqlite.SQLiteDatabase.CursorFactory factory, int databaseVersion, android.database.DatabaseErrorHandler errorHandler)
context
- Associated content from the application. This is needed to locate the database.databaseName
- Name of the database we are opening.factory
- Cursor factory or null if none.databaseVersion
- Version of the database we are opening. This causes onUpgrade(SQLiteDatabase, int, int)
to be
called if the stored database is a different version.errorHandler
- The DatabaseErrorHandler
to be used when sqlite reports database corruption, or null to use the default error handler.public OrmLiteSqliteOpenHelper(android.content.Context context, String databaseName, android.database.sqlite.SQLiteDatabase.CursorFactory factory, int databaseVersion, int configFileId)
OrmLiteConfigUtil
for details.context
- Associated content from the application. This is needed to locate the database.databaseName
- Name of the database we are opening.factory
- Cursor factory or null if none.databaseVersion
- Version of the database we are opening. This causes onUpgrade(SQLiteDatabase, int, int)
to be
called if the stored database is a different version.configFileId
- file-id which probably should be a R.raw.ormlite_config.txt or some static value.public OrmLiteSqliteOpenHelper(android.content.Context context, String databaseName, android.database.sqlite.SQLiteDatabase.CursorFactory factory, int databaseVersion, File configFile)
OrmLiteConfigUtil
for details.context
- Associated content from the application. This is needed to locate the database.databaseName
- Name of the database we are opening.factory
- Cursor factory or null if none.databaseVersion
- Version of the database we are opening. This causes onUpgrade(SQLiteDatabase, int, int)
to be
called if the stored database is a different version.configFile
- Configuration file to be loaded.public OrmLiteSqliteOpenHelper(android.content.Context context, String databaseName, android.database.sqlite.SQLiteDatabase.CursorFactory factory, int databaseVersion, InputStream stream)
OrmLiteConfigUtil
for details.context
- Associated content from the application. This is needed to locate the database.databaseName
- Name of the database we are opening.factory
- Cursor factory or null if none.databaseVersion
- Version of the database we are opening. This causes onUpgrade(SQLiteDatabase, int, int)
to be
called if the stored database is a different version.stream
- Stream opened to the configuration file to be loaded. It will be closed when this method returns.public abstract void onCreate(android.database.sqlite.SQLiteDatabase database, com.j256.ormlite.support.ConnectionSource connectionSource)
NOTE: You should use the connectionSource argument that is passed into this method call or the one returned by getConnectionSource(). If you use your own, a recursive call or other unexpected results may result.
database
- Database being created.connectionSource
- To use get connections to the database to be created.public abstract void onUpgrade(android.database.sqlite.SQLiteDatabase database, com.j256.ormlite.support.ConnectionSource connectionSource, int oldVersion, int newVersion)
NOTE: You should use the connectionSource argument that is passed into this method call or the one returned by getConnectionSource(). If you use your own, a recursive call or other unexpected results may result.
database
- Database being upgraded.connectionSource
- To use get connections to the database to be updated.oldVersion
- The version of the current database so we can know what to do to the database.newVersion
- The version that we are upgrading the database to.public com.j256.ormlite.support.ConnectionSource getConnectionSource()
public final void onCreate(android.database.sqlite.SQLiteDatabase db)
SQLiteOpenHelper.onCreate(SQLiteDatabase)
interface method.onCreate
in class android.database.sqlite.SQLiteOpenHelper
public final void onUpgrade(android.database.sqlite.SQLiteDatabase db, int oldVersion, int newVersion)
SQLiteOpenHelper.onUpgrade(SQLiteDatabase, int, int)
interface method.onUpgrade
in class android.database.sqlite.SQLiteOpenHelper
public void close()
close
in class android.database.sqlite.SQLiteOpenHelper
public boolean isOpen()
close()
is called then this will return false.public <D extends com.j256.ormlite.dao.Dao<T,?>,T> D getDao(Class<T> clazz) throws SQLException
DaoManager
to cache the DAO for future gets.
NOTE: This routing does not return Dao<T, ID> because of casting issues if we are assigning it to a custom DAO. Grumble.
SQLException
public <D extends com.j256.ormlite.dao.RuntimeExceptionDao<T,?>,T> D getRuntimeExceptionDao(Class<T> clazz)
DaoManager
to cache the DAO for future gets.
NOTE: This routing does not return RuntimeExceptionDao<T, ID> because of casting issues if we are assigning it to a custom DAO. Grumble.
This documentation is licensed by Gray Watson under the Creative Commons Attribution-Share Alike 3.0 License.