Skip to content

Commit

Permalink
Done S07.03-ConflictResolutionPolicy
Browse files Browse the repository at this point in the history
  • Loading branch information
Gina committed Sep 29, 2017
1 parent 2668bfa commit e137ffc
Showing 1 changed file with 9 additions and 2 deletions.
Expand Up @@ -44,7 +44,7 @@ public class WeatherDbHelper extends SQLiteOpenHelper {
* use-case, we wanted to watch out for it and warn you what could happen if you mistakenly * use-case, we wanted to watch out for it and warn you what could happen if you mistakenly
* version your databases. * version your databases.
*/ */
private static final int DATABASE_VERSION = 2; private static final int DATABASE_VERSION = 3;


public WeatherDbHelper(Context context) { public WeatherDbHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION); super(context, DATABASE_NAME, null, DATABASE_VERSION);
Expand Down Expand Up @@ -85,9 +85,16 @@ public void onCreate(SQLiteDatabase sqLiteDatabase) {
WeatherEntry.COLUMN_PRESSURE + " REAL NOT NULL, " + WeatherEntry.COLUMN_PRESSURE + " REAL NOT NULL, " +


WeatherEntry.COLUMN_WIND_SPEED + " 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 // 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 * After we've spelled out our SQLite table creation statement above, we actually execute
Expand Down

0 comments on commit e137ffc

Please sign in to comment.