public void showMyEvents() { Log.d("click", "Showing my events"); favoriteview = true; Cursor c = db.query( "event", new String[] {"_id", "isfavorite", "name", "starttime", "endtime"}, "isfavorite = 1", null, null, null, "starttime asc"); dbadapter.changeCursor(c); }
// Called when the star (for favoriting events) next to an event is pressed. public void eventButtonClicked(int event_id, boolean isfavorite) { int isfavorite_dbval; if (isfavorite) isfavorite_dbval = 1; else isfavorite_dbval = 0; ContentValues cv = new ContentValues(); cv.put("isfavorite", isfavorite_dbval); // Update database contents db.update("event", cv, "_id=" + event_id, null); // If event is un-favorited and only favorites are being displayed, // re-create the list to remove the event if (favoriteview && isfavorite_dbval == 0) { Cursor c = db.query( "event", new String[] {"_id", "isfavorite", "name", "starttime", "endtime"}, "isfavorite = 1", null, null, null, "starttime asc"); dbadapter.changeCursor(c); } }