Answer a question

I wish to connect my Android Studio project to a local MongoDB database (on my pc). I cannot find any solutions that do not use MLab, but I really have to use the local MongoDB storage.

I've tried tutorials online, but they still don't work. What should I do?

Answers

The best way to connect a mongo db database to an Android app is via API REST. You can check about that here. Now, if you want to connect your local mongo db with your app is a little bit different process. MLab is a way to deploy a mongo db into the cloud and make it public so any app could connect with that, for that reason all the answers go for that way. One solution could be expose your localhost via ngrok, it's not the best way you dont do that for production it could be useful just for demo or something little.

On resume : Build a rest api with the language of your preference it not affect the result because you always return JSON, then expose your localhost rest api with ngrok and finally connect your rest api with your android app, your base url is the url the ngrok return to you.

Hope this could help. Cheers.

Logo

MongoDB社区为您提供最前沿的新闻资讯和知识内容

更多推荐