void getNoteWithTitle(String note_title) { ArrayList<DBNoteItems> arrinsertedNote = androidOpenDbHelperObj.getAllNotesWithTitle(note_title); for (DBNoteItems dbNoteItems : arrinsertedNote) { System.out.println( "note id: " + dbNoteItems.getNote_Id() + " note_title: " + dbNoteItems.getNote_Title()); SideMenuitems item1 = new SideMenuitems(); item1.setMenuName(dbNoteItems.getNote_Title()); item1.setMenuNameDetail(""); item1.setMenuid(dbNoteItems.getNote_Id()); item1.setColours("#" + dbNoteItems.getNote_Color()); arrDataNote.add(item1); arrDBDataNote.add(dbNoteItems); } adapter.notifyDataSetChanged(); }
/** *********** Fetch all note from database ***************** */ void getallNotes() { arrDataNote.clear(); arrDBDataNote.clear(); ArrayList<DBNoteItems> arrinsertedNote = androidOpenDbHelperObj.getAllNotesWithFolder_Id( DataManager.sharedDataManager().getSelectedFolderId()); for (DBNoteItems dbNoteItems : arrinsertedNote) { System.out.println( "note id: " + dbNoteItems.getNote_Id() + " note_title: " + dbNoteItems.getNote_Title()); SideMenuitems item1 = new SideMenuitems(); item1.setMenuName(dbNoteItems.getNote_Title()); ArrayList<DBNoteItemElement> dbNoteItemElements = androidOpenDbHelperObj.getLastNotesElementWithNote_Id(dbNoteItems.getNote_Id()); item1.setMenuNameDetail( "" + (dbNoteItemElements.size() > 0 ? dbNoteItemElements.get(0).getNOTE_ELEMENT_TYPE() : "")); item1.setMenuid(dbNoteItems.getNote_Id()); if (dbNoteItems.getNote_Color().length() > 0 && dbNoteItems.getNote_Color() != null) { item1.setColours("#" + dbNoteItems.getNote_Color()); } arrDataNote.add(item1); arrDBDataNote.add(dbNoteItems); if (item1.getTimeBomb() != null) { if (!item1.getTimeBomb().equalsIgnoreCase("0")) { SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); formatter.setTimeZone(TimeZone.getTimeZone("GMT")); Date currentdate = new Date(); String strDate = formatter.format(currentdate); try { Date timebombdate = formatter.parse(item1.getTimeBomb().toString()); Date dateCurrent = formatter.parse(strDate); System.out.println(timebombdate); System.out.println(formatter.format(timebombdate)); if (dateCurrent.compareTo(timebombdate) > 0) { System.out.println("Date1 is after Date2 --Delete note here"); } else if (dateCurrent.compareTo(timebombdate) < 0) { System.out.println("Date1 is before Date2"); } else if (dateCurrent.compareTo(timebombdate) == 0) { System.out.println("Date1 is equal to Date2"); } } catch (Exception e) { e.printStackTrace(); } } } } adapter.notifyDataSetChanged(); }