diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2012-10-28 14:06:38 +0100 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2012-10-28 14:06:38 +0100 |
commit | dfc2b4802a9b780ce982bfe2d34e24e93ecb6ed0 (patch) | |
tree | 623e9bef5cbc1ae40a412488a27abd46da593c6a /src/de | |
parent | bd1b07150bf8946fcdce4e067954bc9bf8578cfa (diff) | |
download | AntennaPod-dfc2b4802a9b780ce982bfe2d34e24e93ecb6ed0.zip |
Added methods for searching descriptions of feeditems in the database.
Diffstat (limited to 'src/de')
-rw-r--r-- | src/de/danoeh/antennapod/storage/PodDBAdapter.java | 41 |
1 files changed, 41 insertions, 0 deletions
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 { /** |