public class DatabaseHelper extends SQLiteOpenHelper
Modifier and Type | Class and Description |
---|---|
static interface |
DatabaseHelper.SoundModelContract |
Constructor and Description |
---|
DatabaseHelper(Context context) |
Modifier and Type | Method and Description |
---|---|
boolean |
deleteKeyphraseSoundModel(int keyphraseId,
int userHandle,
String bcp47Locale)
Deletes the sound model and associated keyphrases.
|
SoundTrigger.KeyphraseSoundModel |
getKeyphraseSoundModel(int keyphraseId,
int userHandle,
String bcp47Locale)
Returns a matching
SoundTrigger.KeyphraseSoundModel for the keyphrase ID. |
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 |
updateKeyphraseSoundModel(SoundTrigger.KeyphraseSoundModel soundModel)
Updates the given keyphrase model, adds it, if it doesn't already exist.
|
close, getDatabaseName, getReadableDatabase, getWritableDatabase, onConfigure, onDowngrade, onOpen, setWriteAheadLoggingEnabled
public DatabaseHelper(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 updateKeyphraseSoundModel(SoundTrigger.KeyphraseSoundModel soundModel)
public boolean deleteKeyphraseSoundModel(int keyphraseId, int userHandle, String bcp47Locale)
public SoundTrigger.KeyphraseSoundModel getKeyphraseSoundModel(int keyphraseId, int userHandle, String bcp47Locale)
SoundTrigger.KeyphraseSoundModel
for the keyphrase ID.
Returns null if a match isn't found.
TODO: We only support one keyphrase currently.