diff options
Diffstat (limited to 'src/com/android/photos')
-rw-r--r-- | src/com/android/photos/data/PhotoDatabase.java | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/com/android/photos/data/PhotoDatabase.java b/src/com/android/photos/data/PhotoDatabase.java index a87f00bfa..3a9ad3cb1 100644 --- a/src/com/android/photos/data/PhotoDatabase.java +++ b/src/com/android/photos/data/PhotoDatabase.java @@ -90,12 +90,21 @@ public class PhotoDatabase extends SQLiteOpenHelper { createTable(db, Metadata.TABLE, getMetadataTableDefinition()); } + public PhotoDatabase(Context context, String dbName, int dbVersion) { + super(context, dbName, null, dbVersion); + } + public PhotoDatabase(Context context, String dbName) { super(context, dbName, null, DB_VERSION); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { + dropTable(db, Metadata.TABLE); + dropTable(db, Photos.TABLE); + dropTable(db, Albums.TABLE); + dropTable(db, Accounts.TABLE); + onCreate(db); } protected List<String[]> getAlbumTableDefinition() { @@ -163,4 +172,14 @@ public class PhotoDatabase extends SQLiteOpenHelper { } } } + + protected static void dropTable(SQLiteDatabase db, String table) { + db.beginTransaction(); + try { + db.execSQL("drop table " + table); + db.setTransactionSuccessful(); + } finally { + db.endTransaction(); + } + } } |