DatabaseProviderpublic final class DefaultDatabaseProvider extends Object implements DatabaseProvider
DatabaseProvider that provides instances obtained from a SQLiteOpenHelper.TABLE_PREFIX| Constructor | Description |
|---|---|
DefaultDatabaseProvider(SQLiteOpenHelper sqliteOpenHelper) |
| Modifier and Type | Method | Description |
|---|---|---|
SQLiteDatabase |
getReadableDatabase() |
Creates and/or opens a database.
|
SQLiteDatabase |
getWritableDatabase() |
Creates and/or opens a database that will be used for reading and writing.
|
public DefaultDatabaseProvider(SQLiteOpenHelper sqliteOpenHelper)
sqliteOpenHelper - An SQLiteOpenHelper from which to obtain database instances.public SQLiteDatabase getWritableDatabase()
DatabaseProviderOnce opened successfully, the database is cached, so you can call this method every time you need to write to the database. Errors such as bad permissions or a full disk may cause this method to fail, but future attempts may succeed if the problem is fixed.
getWritableDatabase in interface DatabaseProviderpublic SQLiteDatabase getReadableDatabase()
DatabaseProviderDatabaseProvider.getWritableDatabase() unless some problem, such as a full disk, requires the database to be
opened read-only. In that case, a read-only database object will be returned. If the problem is
fixed, a future call to DatabaseProvider.getWritableDatabase() may succeed, in which case the read-only
database object will be closed and the read/write object will be returned in the future.
Once opened successfully, the database is cached, so you can call this method every time you need to read from the database.
getReadableDatabase in interface DatabaseProviderDatabaseProvider.getWritableDatabase() is called.