Connect Android app to database from website

I need users to register on my site with a username and password.

I basically need to do the following

1. Connect the Android application to the database from the website.

2. Save some information in the database.

3.Wrap some information from the database.

I already have experience using the standard sqlite build in Android apps. The problem is that I need people to register my site and extract some information.

+6
source share
5 answers

To store or retrieve any information stored in a database on a web server, you need to create a simple web service that will transfer requests to the database, and then return the results from the database back to Android in Android format can understand. You can usually send data in POST or REST and then retrieve the data in JSON format.

There is a very good example of how you could achieve this using PHP here . Here you send requests from Android to a PHP script (hosted on the server) using POST, and then the script will return the results in JSON format, which, in turn, can be analyzed by Android to get the desired result.

This is the main method in which sophisticated web services such as twitter, facebook, etc. Most of the interaction is done using REST and JSON.

+9
source

Usually you should not directly connect to the database from the application, because:

  • you need to save the username / password in your application (anyone who can use the decompiler will get it very quickly)
  • Once you have a username / password, you can do something with the database

Based on these points, I would recommend that you install a web service between your application and the database. This web service can be programmed in any programming language that you like. It should protect your database from inadvertent queries in your database.

Then your application connects to your web service, the web service checks the user input and stores it in the database. When you want to get some data from a database, you simply connect to the web service and request the data.

+4
source

The best way is to use Web-Services and implement them to handle all Sql requests sent from your Android client devices.

+1
source

You can use SQLLite to access the database, but I do not know if it is too safe to register, since you need to provide the sql database password.

+1
source

You can use google firebase and Json for your project, you just need to host your web project and you can access your shared database. but you have to make sure that the database you are using is shared by the database.

0
source

Source: https://habr.com/ru/post/909977/


All Articles