MongoDB on Android

Does anyone know how MondgoDB works on Android. Does it work locally and do you replicate data later? Does it work online only with a web backend?

+60
android mongodb
Jul 31 '11 at 6:11
source share
4 answers

I am going to revive this topic and say that the MongoDB Java driver is currently compatible with Android. Some novice developers may have trouble getting their applications to use the MongoDB java library, so I’ll just outline what you need to do (although this may all be outdated by the time you read this).

Browse to the build.gradle file of your application. Add this "compile" entry under your dependencies (you may have to replace the version):

dependencies { ... implementation 'org.mongodb:mongo-java-driver:3.0.3' } 

As you can see, the driver version for this post is 3.0.3. You can find the current version by searching for β€œmongo-java-driver” or any other related term at http://search.maven.org .

If you connect to an external database, of course, you need to add the INTERNET permission to your manifest. Connecting to one is pretty simple. Here is an example. Replace username, password, host domain, port and database name:

 MongoClientURI uri = new MongoClientURI( "mongodb://username:password@www.example.com:12345/db-name" ); MongoClient mongoClient = new MongoClient(uri); MongoDatabase db = mongoClient.getDatabase(uri.getDatabase()); 

Since this is network related, you will need to do all this in the AsyncTask class.

Following the Java tutorials at https://www.mongodb.org/ should be relatively simple from now on.

+35
Sep 12 '15 at 18:27
source share

MongoDB has downloads for several operating systems . However, Android is not one of these systems.

People use MongoDB as a "web service" to store data, but it does not have any features to support multi-wizard replication or your accidentally connected mobile script.

If you need these types of features, you'll want to check out CouchDB , which specifically targets this scenario using Android Couchbase .

+53
Jul 31 '11 at 10:25
source share

Dory mongoDB server

Great New Android App
There is no need to root your phone, and you can run your js file from any of them.


MongoDB (from humongous) is a free and open cross-platform document-oriented database program. Classified as a NoSQL database program, MongoDB uses JSON-like documents with schemas.

Application:
1: install Dory mongoDB server
2: start your server
3: install Dory node.js
4: run this code in js file:

The code:

 var mongoose = require('mongoose'); mongoose.connect('mongodb://localhost/test', { useMongoClient: true }); mongoose.Promise = global.Promise; var Cat = mongoose.model('Cat', { name: String }); var kitty = new Cat({ name: 'Zildjian' }); kitty.save(function (err) { if (err) { console.log(err); } else { console.log('meow'); } }); 

Enjoy. πŸ˜‰

+3
Oct 18 '17 at 23:42 on
source share

Unfortunately, Mongo Java Driver 3.8.0 is no longer compatible with Android: https://gitlab.com/mvysny/umn/issues/1, and they do not even require Android support. Maybe after an unofficial fork or an attempt to GnuSasl can help? Mongodb 3.x driver compatibility for Android

+1
Sep 17 '18 at 13:08
source share



All Articles