From dfc2b4802a9b780ce982bfe2d34e24e93ecb6ed0 Mon Sep 17 00:00:00 2001 From: daniel oeh Date: Sun, 28 Oct 2012 14:06:38 +0100 Subject: [PATCH] Added methods for searching descriptions of feeditems in the database. --- .../antennapod/storage/PodDBAdapter.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/de/danoeh/antennapod/storage/PodDBAdapter.java b/src/de/danoeh/antennapod/storage/PodDBAdapter.java index efe1704b7..6225c13a0 100644 --- a/src/de/danoeh/antennapod/storage/PodDBAdapter.java +++ b/src/de/danoeh/antennapod/storage/PodDBAdapter.java @@ -648,6 +648,47 @@ public class PodDBAdapter { return image; } + /** + * Searches for the given query in the description of all items or the items + * of a specified feed. + * + * @return A cursor with all search results in SEL_FI_EXTRA selection. + * */ + public Cursor searchItemDescriptions(Feed feed, String query) { + if (feed != null) { + // search items in specific feed + return db.query(TABLE_NAME_FEED_ITEMS, SEL_FI_EXTRA, KEY_FEED + + "=? AND " + KEY_DESCRIPTION + " LIKE ?", new String[] { + String.valueOf(feed.getId()), query }, null, null, null); + } else { + // search through all items + return db.query(TABLE_NAME_FEED_ITEMS, SEL_FI_EXTRA, + KEY_DESCRIPTION + " LIKE ?", new String[] { query }, null, + null, null); + } + } + + /** + * Searches for the given query in the content-encoded field of all items or + * the items of a specified feed. + * + * @return A cursor with all search results in SEL_FI_EXTRA selection. + * */ + public Cursor searchItemContentEncoded(Feed feed, String query) { + if (feed != null) { + // search items in specific feed + return db.query(TABLE_NAME_FEED_ITEMS, SEL_FI_EXTRA, KEY_FEED + + "=? AND " + KEY_CONTENT_ENCODED + " LIKE ?", + new String[] { String.valueOf(feed.getId()), query }, null, + null, null); + } else { + // search through all items + return db.query(TABLE_NAME_FEED_ITEMS, SEL_FI_EXTRA, + KEY_CONTENT_ENCODED + " LIKE ?", new String[] { query }, + null, null, null); + } + } + /** Helper class for opening the Antennapod database. */ private static class PodDBHelper extends SQLiteOpenHelper { /**