Couchbase cannot write documents to database
I am new to android and am trying to store an image in a database using couchbase mobile. When I try to run my code, logcat throws the error "Unable to write to the database. The current winning revision is not being removed, so this is a conflict." I don't know what I am doing wrong. Any help is appreciated. Here is my code.
Document document = database.getDocument("test1");
Map<String, Object> docContent = new HashMap<>();
docContent.put("message", "Hello Couchbase Lite");
docContent.put("creationDate", currentTimeString);
docContent.put("Testing Message 1","Testing the sync of message");
try {
document.putProperties(docContent);
UnsavedRevision newRev = document.createRevision();
URL url = new URL("res/mipmap-mdpi-v4/sym_def_app_icon.png");
newRev.setAttachment("photo.png", "image/png", url);
newRev.save();
Log.d (TAG, "Document written to database named " + dbname + " with ID = " + document.getId());
}
catch (CouchbaseLiteException e) {
Log.e(TAG, "Cannot write document to database", e);
}
catch (MalformedURLException e) {
e.printStackTrace();
}
+3
source to share
No one has answered this question yet
Check out similar questions: