How to send documents from my mongodb database to android application?

First of all it’s a bad idea to connect to the Database directly. It is possible, but it’a a bad idea.

It’s a much better practice to create a web service backend that your app can connect to. This will allow you to implement the business logic on the server. And additionally, you will be able to use not only Android, but iOS, AngularJS and others as clients too.

Generally the most common rest backend architecture looks something like this:

I find this way of development to be modular and very well organized.

In short, the API layer only takes HTTP GET and POST methods, and calls the appropriate functions in the Service layer. The service layer holds all of your business logic and calls the DAO layer, and Dao call anb works with the DB.

There’s tons of examples for how to build web services, and it’s highly dependent on your language of choice for your web tier. There are also tons of examples for consuming web services on Android. You should look it up.

But whatever language you choose the API -> Service -> Dao -> Database scheme should work fine.

If you don’t know where to start take a look at Python Flask or Java Spring as good candidates for developing web services. (I use Spring because there is a ton of great documentation on whatever you may need.)

Hope this helps a bit. Good luck!

Browse More Popular Posts

Leave a Comment