public static String addLocation(Database database, Location local) {
   // Create a new document and add data
   Document document = database.createDocument();
   String documentId = document.getId();
   Map<String, Object> map = new HashMap<String, Object>();
   map.put("", "Big Party");
   map.put("location", "My House");
   try {
     // Save the properties to the document
     document.putProperties(map);
   } catch (CouchbaseLiteException e) {
     Log.e(TAG, "Error putting", e);
   }
   return documentId;
 }
Example #2
0
  public static Document createTask(Database database, String title, String listId)
      throws CouchbaseLiteException {
    SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
    Calendar calendar = GregorianCalendar.getInstance();
    String currentTimeString = dateFormatter.format(calendar.getTime());

    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put("type", DOC_TYPE);
    properties.put("title", title);
    properties.put("checked", Boolean.FALSE);
    properties.put("created_at", currentTimeString);
    properties.put("list_id", listId);

    Document document = database.createDocument();
    document.putProperties(properties);

    return document;
  }