public void removeChannel(Channel channel) { SQLiteDatabase database = getWritableDatabase(); clearChannel(channel, database); database.delete("Channel", "id = ?", new String[] {Long.toString(channel.getId())}); database.close(); }
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.menu_irssi_connectbot) { IrssiConnectbotLauncher.launchIrssiConnectbot(this); // MessageGenerator.Flood(this); } else if (item.getItemId() == R.id.menu_settings) { Intent settingsActivity = new Intent(this, SettingsActivity.class); startActivity(settingsActivity); } else if (item.getItemId() == R.id.menu_clear_channel) { DataAccess da = new DataAccess(this); List<Channel> channels = da.getChannels(); Channel channelToClear = null; if (channelToView == null) return true; if (channelToView.equals(FEED)) { da.clearAllMessagesFromFeed(); startMainApp(true); return true; } for (Channel ch : channels) { if (ch.getName().equalsIgnoreCase(channelToView)) { channelToClear = ch; break; } } if (channelToClear != null) { da.clearChannel(channelToClear); startMainApp(true); } } else if (item.getItemId() == R.id.menu_remove_all_channels) { DataAccess da = new DataAccess(this); da.clearAll(); startMainApp(true); } return true; }
public void clearChannel(Channel channel) { SQLiteDatabase database = getWritableDatabase(); clearChannel(channel, database); database.close(); }