diff --git a/src/de/danoeh/antennapod/storage/DBReader.java b/src/de/danoeh/antennapod/storage/DBReader.java index a5a4c8cd4..be38aa3eb 100644 --- a/src/de/danoeh/antennapod/storage/DBReader.java +++ b/src/de/danoeh/antennapod/storage/DBReader.java @@ -313,29 +313,29 @@ public final class DBReader { private static Feed extractFeedFromCursorRow(PodDBAdapter adapter, Cursor cursor) { Date lastUpdate = new Date( - cursor.getLong(PodDBAdapter.KEY_LAST_UPDATE_INDEX)); + cursor.getLong(PodDBAdapter.IDX_FEED_SEL_STD_LASTUPDATE)); final FeedImage image; - long imageIndex = cursor.getLong(PodDBAdapter.KEY_IMAGE_INDEX); + long imageIndex = cursor.getLong(PodDBAdapter.IDX_FEED_SEL_STD_IMAGE); if (imageIndex != 0) { image = getFeedImage(adapter, imageIndex); } else { image = null; } - Feed feed = new Feed(cursor.getLong(PodDBAdapter.KEY_ID_INDEX), + Feed feed = new Feed(cursor.getLong(PodDBAdapter.IDX_FEED_SEL_STD_ID), lastUpdate, - cursor.getString(PodDBAdapter.KEY_TITLE_INDEX), - cursor.getString(PodDBAdapter.KEY_LINK_INDEX), - cursor.getString(PodDBAdapter.KEY_DESCRIPTION_INDEX), - cursor.getString(PodDBAdapter.KEY_PAYMENT_LINK_INDEX), - cursor.getString(PodDBAdapter.KEY_AUTHOR_INDEX), - cursor.getString(PodDBAdapter.KEY_LANGUAGE_INDEX), - cursor.getString(PodDBAdapter.KEY_TYPE_INDEX), - cursor.getString(PodDBAdapter.KEY_FEED_IDENTIFIER_INDEX), + cursor.getString(PodDBAdapter.IDX_FEED_SEL_STD_TITLE), + cursor.getString(PodDBAdapter.IDX_FEED_SEL_STD_LINK), + cursor.getString(PodDBAdapter.IDX_FEED_SEL_STD_DESCRIPTION), + cursor.getString(PodDBAdapter.IDX_FEED_SEL_STD_PAYMENT_LINK), + cursor.getString(PodDBAdapter.IDX_FEED_SEL_STD_AUTHOR), + cursor.getString(PodDBAdapter.IDX_FEED_SEL_STD_LANGUAGE), + cursor.getString(PodDBAdapter.IDX_FEED_SEL_STD_TYPE), + cursor.getString(PodDBAdapter.IDX_FEED_SEL_STD_FEED_IDENTIFIER), image, - cursor.getString(PodDBAdapter.KEY_FILE_URL_INDEX), - cursor.getString(PodDBAdapter.KEY_DOWNLOAD_URL_INDEX), - cursor.getInt(PodDBAdapter.KEY_DOWNLOADED_INDEX) > 0); + cursor.getString(PodDBAdapter.IDX_FEED_SEL_STD_FILE_URL), + cursor.getString(PodDBAdapter.IDX_FEED_SEL_STD_DOWNLOAD_URL), + cursor.getInt(PodDBAdapter.IDX_FEED_SEL_STD_DOWNLOADED) > 0); if (image != null) { image.setFeed(feed); diff --git a/src/de/danoeh/antennapod/storage/PodDBAdapter.java b/src/de/danoeh/antennapod/storage/PodDBAdapter.java index 6d41f6dfd..5f58e9302 100644 --- a/src/de/danoeh/antennapod/storage/PodDBAdapter.java +++ b/src/de/danoeh/antennapod/storage/PodDBAdapter.java @@ -193,11 +193,48 @@ public class PodDBAdapter { private final Context context; private PodDBHelper helper; + /** + * Select all columns from the feed-table except feed preferences. + * */ + private static final String[] FEED_SEL_STD = { + TABLE_NAME_FEEDS + "." + KEY_ID, + TABLE_NAME_FEEDS + "." + KEY_TITLE, + TABLE_NAME_FEEDS + "." + KEY_FILE_URL, + TABLE_NAME_FEEDS + "." + KEY_DOWNLOAD_URL, + TABLE_NAME_FEEDS + "." + KEY_DOWNLOADED, + TABLE_NAME_FEEDS + "." + KEY_LINK, + TABLE_NAME_FEEDS + "." + KEY_DESCRIPTION, + TABLE_NAME_FEEDS + "." + KEY_PAYMENT_LINK, + TABLE_NAME_FEEDS + "." + KEY_LASTUPDATE, + TABLE_NAME_FEEDS + "." + KEY_LANGUAGE, + TABLE_NAME_FEEDS + "." + KEY_AUTHOR, + TABLE_NAME_FEEDS + "." + KEY_IMAGE, + TABLE_NAME_FEEDS + "." + KEY_TYPE, + TABLE_NAME_FEEDS + "." + KEY_FEED_IDENTIFIER + }; + + // column indices for FEED_SEL_STD + public static final int IDX_FEED_SEL_STD_ID = 0; + public static final int IDX_FEED_SEL_STD_TITLE = 1; + public static final int IDX_FEED_SEL_STD_FILE_URL = 2; + public static final int IDX_FEED_SEL_STD_DOWNLOAD_URL = 3; + public static final int IDX_FEED_SEL_STD_DOWNLOADED = 4; + public static final int IDX_FEED_SEL_STD_LINK = 5; + public static final int IDX_FEED_SEL_STD_DESCRIPTION = 6; + public static final int IDX_FEED_SEL_STD_PAYMENT_LINK = 7; + public static final int IDX_FEED_SEL_STD_LASTUPDATE = 8; + public static final int IDX_FEED_SEL_STD_LANGUAGE = 9; + public static final int IDX_FEED_SEL_STD_AUTHOR = 10; + public static final int IDX_FEED_SEL_STD_IMAGE = 11; + public static final int IDX_FEED_SEL_STD_TYPE = 12; + public static final int IDX_FEED_SEL_STD_FEED_IDENTIFIER = 13; + + /** * Select all columns from the feeditems-table except description and * content-encoded. */ - private static final String[] SEL_FI_SMALL = { + private static final String[] FEEDITEM_SEL_FI_SMALL = { TABLE_NAME_FEED_ITEMS + "." + KEY_ID, TABLE_NAME_FEED_ITEMS + "." + KEY_TITLE, TABLE_NAME_FEED_ITEMS + "." + KEY_PUBDATE, @@ -209,16 +246,16 @@ public class PodDBAdapter { TABLE_NAME_FEED_ITEMS + "." + KEY_ITEM_IDENTIFIER}; /** - * Contains SEL_FI_SMALL as comma-separated list. Useful for raw queries. + * Contains FEEDITEM_SEL_FI_SMALL as comma-separated list. Useful for raw queries. */ private static final String SEL_FI_SMALL_STR; static { - String selFiSmall = Arrays.toString(SEL_FI_SMALL); + String selFiSmall = Arrays.toString(FEEDITEM_SEL_FI_SMALL); SEL_FI_SMALL_STR = selFiSmall.substring(1, selFiSmall.length() - 1); } - // column indices for SEL_FI_SMALL + // column indices for FEEDITEM_SEL_FI_SMALL public static final int IDX_FI_SMALL_ID = 0; public static final int IDX_FI_SMALL_TITLE = 1; @@ -663,7 +700,7 @@ public class PodDBAdapter { * @return The cursor of the query */ public final Cursor getAllFeedsCursor() { - Cursor c = db.query(TABLE_NAME_FEEDS, null, null, null, null, null, + Cursor c = db.query(TABLE_NAME_FEEDS, FEED_SEL_STD, null, null, null, null, KEY_TITLE + " ASC"); return c; } @@ -673,14 +710,14 @@ public class PodDBAdapter { } public final Cursor getExpiredFeedsCursor(long expirationTime) { - Cursor c = db.query(TABLE_NAME_FEEDS, null, "?