diff options
author | Kenny Root <kenny@the-b.org> | 2015-09-11 10:55:11 -0700 |
---|---|---|
committer | Kenny Root <kenny@the-b.org> | 2015-09-11 10:55:13 -0700 |
commit | bba1bc399b61459da118b1f6f286ad4164feb89a (patch) | |
tree | 5c3f45ae828ef6e28913cfad38a8e2db34e66350 /app/src/main/java/org | |
parent | 4e8fc54f25b61db74948d99c8fc4c233e0b2f946 (diff) | |
download | connectbot-bba1bc399b61459da118b1f6f286ad4164feb89a.tar.gz connectbot-bba1bc399b61459da118b1f6f286ad4164feb89a.tar.bz2 connectbot-bba1bc399b61459da118b1f6f286ad4164feb89a.zip |
Add back table reset for testing
This seems to be more reliable than other methods.
Diffstat (limited to 'app/src/main/java/org')
-rw-r--r-- | app/src/main/java/org/connectbot/util/HostDatabase.java | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/app/src/main/java/org/connectbot/util/HostDatabase.java b/app/src/main/java/org/connectbot/util/HostDatabase.java index 83fc6be..7c52f79 100644 --- a/app/src/main/java/org/connectbot/util/HostDatabase.java +++ b/app/src/main/java/org/connectbot/util/HostDatabase.java @@ -227,12 +227,28 @@ public class HostDatabase extends RobustSQLiteOpenHelper { } @VisibleForTesting - public static void resetInMemoryInstance(Context context) { - synchronized (sInstanceLock) { - sInstance = new HostDatabase(context, null); + public void resetDatabase() { + try { + mDb.beginTransaction(); + + mDb.execSQL("DROP TABLE IF EXISTS " + TABLE_HOSTS); + mDb.execSQL("DROP TABLE IF EXISTS " + TABLE_PORTFORWARDS); + mDb.execSQL("DROP TABLE IF EXISTS " + TABLE_COLORS); + mDb.execSQL("DROP TABLE IF EXISTS " + TABLE_COLOR_DEFAULTS); + + createTables(mDb); + + mDb.setTransactionSuccessful(); + } finally { + mDb.endTransaction(); } } + @VisibleForTesting + public static void resetInMemoryInstance(Context context) { + get(context).resetDatabase(); + } + @Override public void onRobustUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) throws SQLiteException { // Versions of the database before the Android Market release will be |