Permalink
Browse files

Done S07.02-PreventInvaildInserts

  • Loading branch information...
GinaHsu committed Sep 29, 2017
1 parent 787c094 commit 2668bfa31683e875c40ebd983eca60e1761d0ecb
@@ -44,7 +44,7 @@
* use-case, we wanted to watch out for it and warn you what could happen if you mistakenly
* version your databases.
*/
private static final int DATABASE_VERSION = 1;
private static final int DATABASE_VERSION = 2;
public WeatherDbHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
@@ -75,18 +75,18 @@ public void onCreate(SQLiteDatabase sqLiteDatabase) {
*/
WeatherEntry._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
WeatherEntry.COLUMN_DATE + " INTEGER, " +
WeatherEntry.COLUMN_DATE + " INTEGER NOT NULL, " +
WeatherEntry.COLUMN_WEATHER_ID + " INTEGER, " +
WeatherEntry.COLUMN_WEATHER_ID + " INTEGER NOT NULL, " +
WeatherEntry.COLUMN_MIN_TEMP + " REAL, " +
WeatherEntry.COLUMN_MAX_TEMP + " REAL, " +
WeatherEntry.COLUMN_MIN_TEMP + " REAL NOT NULL, " +
WeatherEntry.COLUMN_MAX_TEMP + " REAL NOT NULL, " +
WeatherEntry.COLUMN_HUMIDITY + " REAL, " +
WeatherEntry.COLUMN_PRESSURE + " REAL, " +
WeatherEntry.COLUMN_HUMIDITY + " REAL NOT NULL, " +
WeatherEntry.COLUMN_PRESSURE + " REAL NOT NULL, " +
WeatherEntry.COLUMN_WIND_SPEED + " REAL, " +
WeatherEntry.COLUMN_DEGREES + " REAL" + ");";
WeatherEntry.COLUMN_WIND_SPEED + " REAL NOT NULL, " +
WeatherEntry.COLUMN_DEGREES + " REAL NOT NULL" + ");";
/*
* After we've spelled out our SQLite table creation statement above, we actually execute
@@ -110,6 +110,9 @@ public void onCreate(SQLiteDatabase sqLiteDatabase) {
@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldVersion, int newVersion) {
// TODO (3) Within onUpgrade, drop the weather table if it exists
sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + WeatherEntry.TABLE_NAME);
// TODO (4) call onCreate and pass in the SQLiteDatabase (passed in to onUpgrade)
onCreate(sqLiteDatabase);
}
}

0 comments on commit 2668bfa

Please sign in to comment.