public static void saveUnreadMessages() { for (int i = ChatHistory.instance.getTotal() - 1; 0 <= i; --i) { Chat chat = ChatHistory.instance.chatAt(i); int unreadMessageCount = chat.getAllUnreadMessageCount(); if (unreadMessageCount == 0) { if (!Options.getBoolean(JLocale.getString(R.string.pref_history))) { HistoryStorage historyStorage = chat.getHistory(); historyStorage.removeHistory(); } } } }