public class DatabaseHelper extends co.touchlab.squeaky.db.sqlite.SqueakyOpenHelper implements AppDatabase
AppDatabase the has no encryption and only has tables
for saving TaskResults and StepResults. You can extend this class and override onCreate and
onUpgrade to add your own tables to those provided by this implementation.
Uses Squeaky, a simple ORM, which uses annotation processing on the model classes to create the tables and add methods for database operations. If you create a subclass of this database class and add more models, you will need to add the annotation processor to your app's build.gradle file: (See the Sample App for details, but add `apt 'co.touchlab.squeaky:squeaky-processor:0.4.0'` to your dependencies and add android-apt: https://bitbucket.org/hvisser/android-apt)
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DEFAULT_NAME |
static int |
DEFAULT_VERSION |
| Constructor and Description |
|---|
DatabaseHelper(android.content.Context context,
java.lang.String name,
android.database.sqlite.SQLiteDatabase.CursorFactory factory,
int version) |
| Modifier and Type | Method and Description |
|---|---|
TaskResult |
loadLatestTaskResult(java.lang.String taskIdentifier)
Loads the latest task result for the given task identifier.
|
java.util.List<StepResult> |
loadStepResults(java.lang.String stepIdentifier)
Returns a list of all StepResults for the given step identifier.
|
java.util.List<TaskResult> |
loadTaskResults(java.lang.String taskIdentifier)
Returns a list of all TaskResults for the given task identifier.
|
void |
onCreate(android.database.sqlite.SQLiteDatabase sqLiteDatabase) |
void |
onUpgrade(android.database.sqlite.SQLiteDatabase sqLiteDatabase,
int i,
int i1) |
void |
saveTaskResult(TaskResult taskResult)
Saves the TaskResult to the database, along with its child StepResults
|
void |
setEncryptionKey(java.lang.String key)
Sets the encryption key on the database.
|
close, getDao, getGeneratedTableMapper, getSqueakyContext, getWrappedDatabasepublic static final java.lang.String DEFAULT_NAME
public static final int DEFAULT_VERSION
public DatabaseHelper(android.content.Context context,
java.lang.String name,
android.database.sqlite.SQLiteDatabase.CursorFactory factory,
int version)
public void onCreate(android.database.sqlite.SQLiteDatabase sqLiteDatabase)
onCreate in class android.database.sqlite.SQLiteOpenHelperpublic void onUpgrade(android.database.sqlite.SQLiteDatabase sqLiteDatabase,
int i,
int i1)
onUpgrade in class android.database.sqlite.SQLiteOpenHelperpublic void saveTaskResult(TaskResult taskResult)
AppDatabasesaveTaskResult in interface AppDatabasetaskResult - the task result to savepublic TaskResult loadLatestTaskResult(java.lang.String taskIdentifier)
AppDatabaseThis can be used to see when the user last answered the survey, or to get their most recent answer to a survey question.
loadLatestTaskResult in interface AppDatabasetaskIdentifier - the task identifierpublic java.util.List<TaskResult> loadTaskResults(java.lang.String taskIdentifier)
AppDatabaseloadTaskResults in interface AppDatabasetaskIdentifier - the task identifierpublic java.util.List<StepResult> loadStepResults(java.lang.String stepIdentifier)
AppDatabaseloadStepResults in interface AppDatabasestepIdentifier - the step identifierpublic void setEncryptionKey(java.lang.String key)
AppDatabasesetEncryptionKey in interface AppDatabasekey - a string key to be used to encrypt the database