public class DayDataDBH
extends android.database.sqlite.SQLiteOpenHelper
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
COLUMN_CALORIC_GOAL |
static java.lang.String |
COLUMN_CARBS_GOAL |
static java.lang.String |
COLUMN_DATE |
static java.lang.String |
COLUMN_FAT_GOAL |
static java.lang.String |
COLUMN_ID |
static java.lang.String |
COLUMN_PROTEIN_GOAL |
static java.lang.String |
COLUMN_WATER_GOAL |
static java.lang.String |
COLUMN_WATER_INTAKE |
static java.lang.String |
COLUMN_WEIGHT |
static java.lang.String |
DAYDATA_TABLE |
Constructor and Description |
---|
DayDataDBH(android.content.Context context)
On first construction, creates a database with a name and a version
|
Modifier and Type | Method and Description |
---|---|
void |
addOneIgnore(java.lang.String date,
int weight,
int caloricGoal,
int carbsGoal,
int proteinGoal,
int fatGoal,
int waterGoal,
int waterIntake)
Adds a new row if no data exists for the given date.
|
void |
addOneReplace(java.lang.String date,
int weight,
int caloricGoal,
int carbsGoal,
int proteinGoal,
int fatGoal,
int waterGoal,
int waterIntake)
Adds a new row or replaces an existing one.
|
int |
getIntByDate(java.lang.String column,
java.lang.String date)
Getting data from a column in the database given a certain date
|
void |
onCreate(android.database.sqlite.SQLiteDatabase db)
Used only the first time.
|
void |
onUpgrade(android.database.sqlite.SQLiteDatabase db,
int oldVersion,
int newVersion)
Handles actions on upgrade to another version.
|
void |
updateColumnWhereDateTo(java.lang.String column,
java.lang.String date,
int newValue)
Update a column with new given values on a given date
|
public static final java.lang.String COLUMN_ID
public static final java.lang.String DAYDATA_TABLE
public static final java.lang.String COLUMN_DATE
public static final java.lang.String COLUMN_WEIGHT
public static final java.lang.String COLUMN_CALORIC_GOAL
public static final java.lang.String COLUMN_CARBS_GOAL
public static final java.lang.String COLUMN_PROTEIN_GOAL
public static final java.lang.String COLUMN_FAT_GOAL
public static final java.lang.String COLUMN_WATER_GOAL
public static final java.lang.String COLUMN_WATER_INTAKE
public DayDataDBH(@Nullable android.content.Context context)
context
- activity classpublic void onCreate(android.database.sqlite.SQLiteDatabase db)
onCreate
in class android.database.sqlite.SQLiteOpenHelper
db
- database createdpublic void onUpgrade(android.database.sqlite.SQLiteDatabase db, int oldVersion, int newVersion)
onUpgrade
in class android.database.sqlite.SQLiteOpenHelper
db
- database upgradedoldVersion
- newVersion
- public void addOneReplace(java.lang.String date, int weight, int caloricGoal, int carbsGoal, int proteinGoal, int fatGoal, int waterGoal, int waterIntake)
date
- date of dataweight
- weight input by user for that datecaloricGoal
- calorie intake goal input by user for that datecarbsGoal
- carb intake goal input by user for that dateproteinGoal
- protein intake goal input by user for that datefatGoal
- fat intake goal input by user for that datewaterGoal
- water intake goal input by user for that datewaterIntake
- water intake input by user for that daypublic void addOneIgnore(java.lang.String date, int weight, int caloricGoal, int carbsGoal, int proteinGoal, int fatGoal, int waterGoal, int waterIntake)
date
- date of dataweight
- weight input by user for that datecaloricGoal
- calorie intake goal input by user for that datecarbsGoal
- carb intake goal input by user for that dateproteinGoal
- protein intake goal input by user for that datefatGoal
- fat intake goal input by user for that datewaterGoal
- water intake goal input by user for that datewaterIntake
- water intake input by user for that daypublic int getIntByDate(java.lang.String column, java.lang.String date)
column
- column name of the data to be fetcheddate
- date at which the data should be fetchedpublic void updateColumnWhereDateTo(java.lang.String column, java.lang.String date, int newValue)
column
- column to be updateddate
- date where the modification should happennewValue
- new value for the column