Mobile App: MySQL Connection [duplicate] - android

This question already has an answer here:
Proper architecture for iOS connecting to database?
(1 answer)
Closed 9 years ago.
I want to develop a native App for Android and iOS. The App communicates with a MySQL DB on an online server.
What's the best way to do this? Store the DB in the App or communicate with a live DB on a server right within the App? Is it secure to connect right from the App to the DB?

When I need an app to communicate with a database, I use a server-side script (written in PHP).
Sample flow:
App performs an HTTP POST and includes all required variables in the
header.
The script on the server queries the database.
The script returns the data as a JSON/XML array.
This sort of a configuration has several benefits, the most important one being that you do not have to distribute your database passwords - even if you encrypt them, it is a risk. You can also monitor/record/refuse connections with ease.
Finally, this implementation is platform-independent and will work on both Android and iOS.
This technique has worked successfully for me however, YMMV.

The only way you would be able to store the database within the app was if it was a flatfile database.
You should not have any problems connecting to a MySql database on a server and if you want extra security encrypt your password and unencrypt it when you need to use it.

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.

What SQL databases are used in Android to build a simple app with a login system?

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.

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)

Choosing Correct Database for My Needs

I am in the preliminary stages of designing a smartphone app (will be available on iOS, Android, Windows Phone). I am just learning all of this. I am trying to find the right database for my needs.
This database will eventually have high-traffic, has to be able to integrate into an app, and maybe even use a website later on. The app will send and receive data from the database. Any advice on this would be greatly appreciated.
I know SQLite works well in apps, but can it support high-traffic apps that have users uploading a lot of data at the same time? To recap, it must be: accessible from an app, support high-traffic, send and receive data.
I would reccommend MySQL, which I see you have tagged in your question already. I'm using MySQL for a Survey applcation and I havent had any problems with it. I get information from the Server via php.
Basic outline of what my app does:
iPhone App connects to the url for the php script, inputting correct arguments --> php script contacts the database --> php returns values --> iphone app stores the variables for use in obj-c
You can store sqlite database right in your application, but I never needed to do so. Hope this helps.

syncing android database with server with intermittent internet conectivity

so I am writing an android app that will be used at a point of sale in some shops for survey questions. I have a java jsf web app using jpa with a mysql database that I want to sync with, preferably both ways but only a couple of tables. The android app will have only a few tables and will not replicate my server database completely. Unfortunately the android apps will in some places have only intermittent internet access that will drop in and out. I am currently looking at different options to use to store my data on android. I have looked at:
writing my own sync between the database on my server and SQLite on android but there has to be an easier option
storing my data on app engine and syncing with app engine as per the example in the android developers guide however I am not sure how my limited internet connectivity will work
using couchdb but I dont really want to go down this route as I already have the server side set up
does anyone have any ideas?
can I store data locally using android then sync with app engine when I have a connection?
Thanks

Categories

Resources