From: Luke Owncloud Date: Thu, 11 Dec 2014 07:32:38 +0000 (+0100) Subject: on downgrading upload db, delete and re-create X-Git-Tag: oc-android-1.7.0_signed~35^2 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/1077a6de2977b61d46abefb3a30d393185f40d96?ds=inline;hp=--cc on downgrading upload db, delete and re-create --- 1077a6de2977b61d46abefb3a30d393185f40d96 diff --git a/src/com/owncloud/android/db/DbHandler.java b/src/com/owncloud/android/db/DbHandler.java index 717066b7..3682a7b2 100644 --- a/src/com/owncloud/android/db/DbHandler.java +++ b/src/com/owncloud/android/db/DbHandler.java @@ -114,7 +114,14 @@ public class DbHandler { db.execSQL("ALTER TABLE " + TABLE_INSTANT_UPLOAD + " ADD COLUMN attempt INTEGER;"); } db.execSQL("ALTER TABLE " + TABLE_INSTANT_UPLOAD + " ADD COLUMN message TEXT;"); - + } + + @Override + public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) { + //downgrading is the exception, so deleting and re-creating is acceptable. + //otherwise exception will be thrown (cannot downgrade) and oc app will crash. + db.execSQL("DROP TABLE IF EXISTS " + TABLE_INSTANT_UPLOAD + ";"); + onCreate(db); } } }