private boolean updateNotes() { ArrayList<AppNote> changed = mDbHelper.fetchNotes(NotesDbAdapter.CHANGED_NOTES_SELECTION); boolean allUpdated = true; for (AppNote appNote : changed) { try { link.update(appNote.getNote()); mDbHelper.updateNote(appNote.getId(), appNote.getNote(), true); } catch (LinkItemNotFound e) { e.printStackTrace(); try { link.add(appNote.getNote()); mDbHelper.updateNote(appNote.getId(), appNote.getNote(), true); } catch (LibOperaLinkException e1) { e1.printStackTrace(); allUpdated = false; } } catch (LinkAccessDeniedException e) { e.printStackTrace(); isConnected = false; allUpdated = false; } catch (LibOperaLinkException e) { e.printStackTrace(); allUpdated = false; } } return allUpdated; }
/** * Delete notes which were marked as those to be deleted, delete them also from the Opera Link * server * * @return true if deleting notes at the server succeeded */ private boolean deleteNotes() { ArrayList<AppNote> toDelete = mDbHelper.fetchNotes(NotesDbAdapter.TO_DELETE_SELECTION); boolean allDeleted = true; for (AppNote appNote : toDelete) { try { if (appNote.getOpera_id() != null) { link.delete(appNote.getNote()); } mDbHelper.deleteNote(appNote.getId()); } catch (LinkItemNotFound e) { e.printStackTrace(); mDbHelper.deleteNote(appNote.getId()); } catch (LinkAccessDeniedException e) { e.printStackTrace(); isConnected = false; allDeleted = false; } catch (LibOperaLinkException e) { e.printStackTrace(); allDeleted = false; } } return allDeleted; }