How to access PostgreSQL database data from an Android App? - android

I am making an app which requires a database, so I want to use PostgreSQL from Google Cloud Platform, I did not find any tutorials helping me to do that, How to access the data? a link at Can i use PostgreSQL or mySQL in android App development
no longer works or outdated, found the REST API documentation for Cloud SQL but unable to understand if these APIs are just to access DATABASE or the data inside DATABASE?

As mentioned in the accepted answer to the post suggested by #JGH, there are a few ways to access data of a DB from an Android App.
The most commonly used way is definitely by communicating to a service hosted on a server that can connect to the DB, and provides endpoints to request any operation (read, write, update, delete).
However, since you specified a direct connection from the Android App to the Cloud SQL instance, the best option would be to try to make it work with the JDBC connecting to, possibly, a public IP of the Cloud SQL instance. You may find more information in the Connecting to Cloud SQL from external applications documentation.

Related

How to access postgreSQL database from android mobile using python

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.

Connecting Android Application to MySQL Database hosted on AWS

Good day everyone,
I have developed an android application and I would like to store my business information on MySQL database. I have decided to use amazon services for this project however I'm very confused how to allow my application to establish a proper/secure connection with MySQL database in order to pull and push the information into it. I have read many articles/stack overflow posts and realized I have to deploy a REST api in order to provide a layer between the application and the actual database. However with AWS being very confusing, in my opinion, i'm super lost.
Could any of you gentle folks provided with the step-by-step guide what services to use, how to connect them together and deploy them in order to be able to use it in my android application. Or maybe an article describing the steps? I don't really need a detailed explanation just a nudge in the right direction and I will try to figure out the rest.
Thank you greatly.
First of all, connecting to MySQL directly from an Android application is not secure, since you need the MySQL database access credentials for the app to communicate with the database.
This is why people recommend using a REST API Layer in between the MySQL database which you can implement using API Gateway and Lambda. This can be secured using a strong authentication mechanism for the API and using SSL for encrypting the messages at Transit.
However, this is not the case if you plan to connect to AWS DynamoDB from Android App. You can enforce Fine-Grained Access Permission to DynamoDB tables and roles using IAM policies.
Few Tutorials that might help,
Serverless REST API in Minutes with Serverless Framework.
Querying RDS MySQL with NodeJS Lambda Function.
Using Mobile Hub (To Simplify Things).
User Authentication with Cognito UserPools.

Is it possible to remotely run queries to a database on a device through a web interface?

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)

Connecting Android to AWS RDS [duplicate]

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.

Connecting Android app to amazon RDS

I have an Android application and I want to move my local database in the cloud. I decided for a SQL database and not for a NoSQL, because I want to execute complex queries. I created a database instance in RDS from Amazon and I populated the database.
Now I want to connect my mobile app to my cloud database. I saw samples for NoSQL database connection, but I wasn't able to find examples for RDS. I saw that it is recommended to create a web service and connect to that web service, but it seems much more complicated than using a NoSQL and this doesn't feel right.
Does Amazon offer some API/service for Android - RDS connection? Do you know any sample code that handles this aspect?
Does Amazon offer some API/service for Android - RDS connection?
No. AWS does not currently have an API for interacting with an RDS instance.
Do you know any sample code that handles this aspect?
You may want to access your database with PHP and get a JSON response. If your RDS instance is using MySQL then you’re in luck. There is already a lot of documentation on connecting Android to MySQL using PHP. You can get great sample code and instructions on this blog post.
Here is a very popular reference for connecting Android and MySQL.

Categories

Resources