/** * c-R-ud * * @param docId * @return Doc content */ public Map<String, Object> retrieve(String docId) { Map<String, Object> map = new HashMap<String, Object>(); if (database == null) { return map; } // retrieve the document from the database Document doc = database.getExistingDocument(docId); if (doc != null) { // display the retrieved document map = doc.getProperties(); } return map; }
/** * cru-D * * @param docId * @return */ public boolean delete(String docId) { if (database == null) { Log.e("DatabaseWrapper", "database is null : DatabaseWrapper.delete(" + docId + ")"); return false; } Document doc = null; // delete the document try { if (!database.isOpen()) { database.open(); } doc = database.getExistingDocument(docId); if (doc != null) { doc.delete(); } } catch (CouchbaseLiteException e) { e.printStackTrace(); } if (doc != null) { return doc.isDeleted(); } return false; }