just clear the database tables, don't delete the whole DB.

This commit is contained in:
Tom Hennen 2015-11-27 09:22:50 -05:00
parent 69038b4ff5
commit b5ea846bb1
1 changed files with 20 additions and 8 deletions

View File

@ -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;
}
/**