How can I create an android app that uses a mongoDB database locally i.e. Clients can make CRUD operations without connecting to a server. Sort of how SQLite is used, except this time I wanna use mongoDB.
I have checked around and what seems to be my most suitable option is using mongodb java driver, but the problem is how and what am I connecting the mongoClient to? Do I have to sort of start a server or something?
I would suggest using firebase or realm or something that comes with better native mobile support. Couchbase Mobile might be of interest too, but I have not used it. https://developer.couchbase.com/mobile
Related
I wand to access the postgreSQL database from android using Pydroid3 application in my mobile phone. to access postgreSQL database i need to import psycopg2, but android doesn't support this.
can anyone please suggest the way to solve this issue.
With Android you typically don't make a hard database connection, unless its a local one.
psycopg2 doesn't work for the same reason you're not supposed to use JDBC . You should talk to a remote database via a RESTful API, meaning a server sends you data that it itself retrieves from the database.
So your next step would to create a web site/service that handles GET requests. So your app can talk to it, and it can talk to the database.
I'm trying to build an Android app where the database is on the server side.I hear that SQLite is a local database so it doesn't really work for what I'm trying to do.
In java I would use JDBC to connect to MySQL and send requests normally.
In PHP too it's almost the same thing.
The app needs a login system and all of that...
How can I do this in Android ?
Android does not support MySQL out of the box, but you can implement it.
Probably the SQLite you heard about, in the Android environment, refers to Room, the standard to save persistent data locally on the device.
In the mobile world, often a good option (if they fits for you) are NoSQL databases. There are plenty, hosted services like Firebase, DynamoDB or open source like MongoDB, Supabase.
So far I think it's a security thing that you're not allowed reading/writing to an Android SQLite database outside of the containing app's process.
But are there advanced techniques or tools that can be used to achieve this?
For instance, I want to make a web interface with a textbox where the Android app would connect to and then I can run SQL queries via said interface to read the database or to insert records into it.
I'm writing this question because I'm really stumped. Usually my search gives opposite results which is accessing a remote database with an Android app.
You will have to develop an API backend. The mobile app ( client ) will communicate with the API and do the desired operation based on the response.
It's not possible to directly connect to the app sqlite database. You can send web request and get the info you want, handle it in your app to store it in the sqlite database
You will have to add security measures, so everyone can't access your API.
So far I think it's a security thing that you're not allowed reading/writing to an Android SQLite database.
Apps can read and write to their SQLite databases. Otherwise, the database would not exist.
I want to make a web interface with a textbox where the Android app would connect to and then I can run SQL queries via said interface to read the database or to insert records into it.
You are certainly welcome to embed a Web server into your app. For example, Stetho does this to integrate with Chrome Dev Tools, offering your SQL interface among other things.
However:
Doing this for anything other than a debug build of your app is very risky, as securing a Web server is difficult enough when it is on a traditional server environment, let alone an Android device
The Web server is only accessible by whatever can reach the device via an IP address, which means it's usually only useful on WiFi (where it could be reached by other devices on the same WiFi LAN segment)
Background
I have a EC2 instance with a RDS instance(MYSQL) associated with it.
I want to use a android app to execute queries on that MYSQL instance.The Android sdk of amazon does not support RDS.
Problem
How do I connect my android app with RDS instance?Is it possible to use RDS(MYSQL) with an android application without sdk support?
RDS is not a database engine. It's a service that manages the infrastructure for you that's required to maintain a highly available and fault tolerant database. It supports a number of different engines such as MySQL as you mentioned. Please read the docs for more information.
You need to connect to your RDS MySQL instance the same way you would connect to any MySQL database. Using a library that supports MySQL, and using the hostname, username and password for your database.
However, it's probably not the best design to have phone clients connecting to your database remotely. The best thing to do would be to put a REST API on AWS that interfaces with your database.
Having n users connected to your database from each handset using your app is probably a bad idea. It means you need to have more power in your database, greatly hinders your scalability and makes things less secure as the database is exposed to the internet. With an API in front of it, you can build a much more fault tolerant, scalable and solution.
The "cloud way" to build mobile apps is to (within reason) build your application logic on the cloud and simply have your client code connect to your API. This way you can spread to more platforms (eg. IOS, Web) much more easily as you won't have to manage separate application level code for each platform. You'll just need to manage code that integrates with your already existing API.
Take a look at this whitepaper. Ignore the web server tier and focus on the App Server and Database tiers. This is probably the best design to go by.
Background
I have a EC2 instance with a RDS instance(MYSQL) associated with it.
I want to use a android app to execute queries on that MYSQL instance.The Android sdk of amazon does not support RDS.
Problem
How do I connect my android app with RDS instance?Is it possible to use RDS(MYSQL) with an android application without sdk support?
RDS is not a database engine. It's a service that manages the infrastructure for you that's required to maintain a highly available and fault tolerant database. It supports a number of different engines such as MySQL as you mentioned. Please read the docs for more information.
You need to connect to your RDS MySQL instance the same way you would connect to any MySQL database. Using a library that supports MySQL, and using the hostname, username and password for your database.
However, it's probably not the best design to have phone clients connecting to your database remotely. The best thing to do would be to put a REST API on AWS that interfaces with your database.
Having n users connected to your database from each handset using your app is probably a bad idea. It means you need to have more power in your database, greatly hinders your scalability and makes things less secure as the database is exposed to the internet. With an API in front of it, you can build a much more fault tolerant, scalable and solution.
The "cloud way" to build mobile apps is to (within reason) build your application logic on the cloud and simply have your client code connect to your API. This way you can spread to more platforms (eg. IOS, Web) much more easily as you won't have to manage separate application level code for each platform. You'll just need to manage code that integrates with your already existing API.
Take a look at this whitepaper. Ignore the web server tier and focus on the App Server and Database tiers. This is probably the best design to go by.