Permalink
Browse files

Done S07.03-ConflictResolutionPolicy

  • Loading branch information...
GinaHsu committed Sep 29, 2017
1 parent 2668bfa commit e137ffc45b6d48286056b0f2de0aacd422200451
@@ -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 = 2;
private static final int DATABASE_VERSION = 3;
public WeatherDbHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
@@ -85,9 +85,16 @@ public void onCreate(SQLiteDatabase sqLiteDatabase) {
WeatherEntry.COLUMN_PRESSURE + " REAL NOT NULL, " +
WeatherEntry.COLUMN_WIND_SPEED + " REAL NOT NULL, " +
WeatherEntry.COLUMN_DEGREES + " REAL NOT NULL" + ");";
WeatherEntry.COLUMN_DEGREES + " REAL NOT NULL, " +
// TODO (1) Add a UNIQUE constraint on the date column to replace on conflict
/*
* To ensure this table can only contain one weather entry per date, we declare
* the date column to be unique. We also specify "ON CONFLICT REPLACE". This tells
* SQLite that if we have a weather entry for a certain date and we attempt to
* insert another weather entry with that date, we replace the old weather entry.
*/
" UNIQUE (" + WeatherEntry.COLUMN_DATE + ") ON CONFLICT REPLACE);";
/*
* After we've spelled out our SQLite table creation statement above, we actually execute

0 comments on commit e137ffc

Please sign in to comment.