From 3d27cf220acfa95b1838832f5e1db0eeaadd4cd5 Mon Sep 17 00:00:00 2001 From: cketti Date: Sun, 29 Aug 2010 18:46:51 +0000 Subject: [PATCH] Removed some code/string duplication. --- src/com/fsck/k9/mail/store/LocalStore.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/com/fsck/k9/mail/store/LocalStore.java b/src/com/fsck/k9/mail/store/LocalStore.java index 7e210c246..194b76a61 100644 --- a/src/com/fsck/k9/mail/store/LocalStore.java +++ b/src/com/fsck/k9/mail/store/LocalStore.java @@ -2189,24 +2189,23 @@ public class LocalStore extends Store implements Serializable public void deleteMessagesOlderThan(long cutoff) throws MessagingException { + final String where = "folder_id = ? and date < ?"; + final String[] params = new String[] { + Long.toString(mFolderId), Long.toString(cutoff) + }; + open(OpenMode.READ_ONLY); Message[] messages = LocalStore.this.getMessages( null, this, - "SELECT " + GET_MESSAGES_COLS - + "FROM messages WHERE folder_id = ? and date < ?", new String[] - { - Long.toString(mFolderId), Long.toString(cutoff) - }); + "SELECT " + GET_MESSAGES_COLS + "FROM messages WHERE " + where, + params); for (Message message : messages) { deleteAttachments(message.getUid()); } - mDb.execSQL("DELETE FROM messages WHERE folder_id = ? and date < ?", new Object[] - { - Long.toString(mFolderId), new Long(cutoff) - }); + mDb.execSQL("DELETE FROM messages WHERE " + where, params); resetUnreadAndFlaggedCounts(); }