From b5ea846bb1f179d8d6830087577c68b8945ffdc5 Mon Sep 17 00:00:00 2001 From: Tom Hennen Date: Fri, 27 Nov 2015 09:22:50 -0500 Subject: just clear the database tables, don't delete the whole DB. --- .../antennapod/core/storage/PodDBAdapter.java | 28 +++++++++++++++------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'core/src/main/java') diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java b/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java index c67fb956a..bf324c9d1 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java @@ -263,6 +263,20 @@ public class PodDBAdapter { TABLE_NAME_FEED_ITEMS + "." + KEY_AUTO_DOWNLOAD }; + /** + * All the tables in the database + */ + private static final String[] ALL_TABLES = { + TABLE_NAME_FEEDS, + TABLE_NAME_FEED_ITEMS, + TABLE_NAME_FEED_IMAGES, + TABLE_NAME_FEED_MEDIA, + TABLE_NAME_DOWNLOAD_LOG, + TABLE_NAME_QUEUE, + TABLE_NAME_SIMPLECHAPTERS, + TABLE_NAME_FAVORITES + }; + /** * Contains FEEDITEM_SEL_FI_SMALL as comma-separated list. Useful for raw queries. */ @@ -325,15 +339,13 @@ public class PodDBAdapter { } public static boolean deleteDatabase() { - if(dbHelper != null) { - dbHelper.close(); - dbHelper = null; - } - if(context != null) { // may not have been initialized - return context.deleteDatabase(PodDBAdapter.DATABASE_NAME); - } else { - return false; + PodDBAdapter adapter = getInstance(); + adapter.open(); + for (String tableName : ALL_TABLES) { + db.delete(tableName, "1", null); } + adapter.close(); + return true; } /** -- cgit v1.2.3