public class SoundTriggerDbHelper extends SQLiteOpenHelper
Modifier and Type | Class and Description |
---|---|
static interface |
SoundTriggerDbHelper.GenericSoundModelContract |
Constructor and Description |
---|
SoundTriggerDbHelper(Context context) |
Modifier and Type | Method and Description |
---|---|
boolean |
deleteGenericSoundModel(UUID model_uuid) |
SoundTrigger.GenericSoundModel |
getGenericSoundModel(UUID model_uuid) |
void |
onCreate(SQLiteDatabase db)
Called when the database is created for the first time.
|
void |
onUpgrade(SQLiteDatabase db,
int oldVersion,
int newVersion)
Called when the database needs to be upgraded.
|
boolean |
updateGenericSoundModel(SoundTrigger.GenericSoundModel soundModel)
Updates the given sound trigger model, adds it, if it doesn't already exist.
|
close, getDatabaseName, getReadableDatabase, getWritableDatabase, onConfigure, onDowngrade, onOpen, setWriteAheadLoggingEnabled
public SoundTriggerDbHelper(Context context)
public void onCreate(SQLiteDatabase db)
SQLiteOpenHelper
onCreate
in class SQLiteOpenHelper
db
- The database.public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
SQLiteOpenHelper
The SQLite ALTER TABLE documentation can be found here. If you add new columns you can use ALTER TABLE to insert them into a live table. If you rename or remove columns you can use ALTER TABLE to rename the old table, then create the new table and then populate the new table with the contents of the old table.
This method executes within a transaction. If an exception is thrown, all changes will automatically be rolled back.
onUpgrade
in class SQLiteOpenHelper
db
- The database.oldVersion
- The old database version.newVersion
- The new database version.public boolean updateGenericSoundModel(SoundTrigger.GenericSoundModel soundModel)
public SoundTrigger.GenericSoundModel getGenericSoundModel(UUID model_uuid)
public boolean deleteGenericSoundModel(UUID model_uuid)