I need nosql database so I used couchbase lite to store data. I dont know if I need sync_gateway and if needed then how to make sync_gateway_config.json file to store data from mobile app to couchbase server?
This is manager
try {
manager = new Manager(new AndroidContext(getApplicationContext()),
Manager.DEFAULT_OPTIONS);
Manager.enableLogging("Sync", Log.VERBOSE);
} catch (IOException e) {
e.printStackTrace();
}
try {
database = manager.getDatabase("app");
} catch (CouchbaseLiteException e) {
e.printStackTrace();
}
and This is Document
Map properties = new HashMap(); properties.put("p1x", p1[0]); properties.put("p1y", p1[1]); properties.put("p2x", p2[0]); properties.put("p2y", p2[1]); properties.put("p3x", p3[0]); properties.put("p3y", p3[1]); properties.put("x", finalX); properties.put("y", finalY); // Create a new document Document document = database.createDocument(); // Save the document to the database try { document.putProperties(properties); } catch (CouchbaseLiteException e) { e.printStackTrace(); } // Log the document ID (generated by the database) // and properties Log.d("app", String.format("Document ID :: %s", document.getId())); Log.d("app", String.format("coordinate x : %s %s , coordinate y : %s %s , coordinate z : %s %s , finalx : %s finaly : %s", document.getProperty(String.valueOf("p1x")), document.getProperty(String.valueOf("p1y")), document.getProperty(String.valueOf("p2x")), document.getProperty(String.valueOf("p2y")), document.getProperty(String.valueOf("p3x")), document.getProperty(String.valueOf("p3y")), document.getProperty(String.valueOf("x")), document.getProperty(String.valueOf("y")))); URL url = null; try { url = new URL("http://127.0.0.1:8091/wifi"); } catch (MalformedURLException e) { e.printStackTrace(); } Replication push = database.createPushReplication(url); Replication pull = database.createPullReplication(url); push.setContinuous(true); pull.setContinuous(true);
Sync_gateway_config file
{ "databases": { "db": { "bucket": "wifi", "username": "admin", "password": "adminadmin", "server": "http://localhost:8091", "enable_shared_bucket_access": true, "import_docs": "continuous" } } } enter code here