Connect webhost database to android database - php

I developed a web application based on PHP, now I built an android application too.
I know I can use SQLite for storing information, but I want to connect android database to my webhost database so that the information can be accessible by two applications.
Is it possible? If yes, how?

There is no direct way to access database outside device, you need to write some web services which will return data in json (better option) or xml format and then you can parse it and use information.

You could use PHP script in order to accomplish that.
http://www.basic4ppc.com/android/forum/threads/connect-android-to-mysql-database-tutorial.8339/

Although Full implementation requires lot of code and instead of reinventing the wheel its better u checkout smart implementation given in the links below which will help u out.
The following Tutorial #01 and Tutorial #02 might help you out.
1- Connect Android to Remote Database
2- Using Json (API) to parse data from and into android to server
3- Parse Request and Process
4- Save Information in Local Android Sqllite database.

Related

What's the best way to connect an Android App to MySQL?

I would like to write an Android App (with Android Studio) which uses a MySQL database.
What's the best way to implement it?
I have found on internet that I should write php files which send queries to the database. Then the php page return a JSON object which should be processed by the Android App (or something like that...).
Is this solution safe? Because I have to handle sensitive data like emails or GPS position.
Or else, are there other safe ways to let Android App connect to and retrieve information from the database?
You can call a web service which connects to your server, and a back-end program written in nodejs or PHP or Java or Python or any other programming language which has support (connectors/libraries) for MySQL database.

Connecting an Android application to a database

I need to connect my mobile app to a database so it can send information from the app to the database.
I have looked at a ton of tutorials but they seem to irrelevant to my situation or write the entire application in XML. Can I connect it through script tags in the app or do I need to connect to via PHP and if I do where do I place that file in the application?
It is not clear to me if it is a local database on your phone or not.
If it is a local database on your phone I would use android's api.
If it is not, the best option is to write a SOAP or Rest service which need to run on a server. Personally I would go for a REST service, because it is less complicated. Although if there is sensitive data it might be better to use a SOAP service. You might take a look at this.
For calling your Rest services you could use a httpwebrequest. I belief this is an good example.
Write ur database related code in php and from your app send the post or get parametized url so it can be stored to ur phpmyadmin db

Connecting MySql with Android without using PHP

I want to connect a MySql DB with my android application.
However, I DON'T want to/CAN'T use PHP for doing this.
Almost all solution for MySql connection with android on internet uses PHP.
I read somewhere that, If one don't want to use PHP then web service should be used.
But I'm not able to find any tutorial/sample example for the same.
Any help appreciated.
It seems you're mixing up some things.
A web service is simply some code on the internet (web) which allows you to receive and send information to a server, where it is saved per example in a database.
PHP is just a language, in which you can write a web service.
You can use a vast array of languages to create a web service ( read: expose your database) to other devices. Among others, you can easily do this in Java, .NET, Python ...
If you're looking for a way to connect to an external database without any web service / API in between, i'll have to disappoint you with the news that this is not supported by Android.
Most examples of a simple web service / a bunch of scripts contain PHP since this is probably the easiest and can be used on pretty much any server.
A webservice, is as it's called, a service, meaning that you have one side consuming it (the android client). if all you want is a persistent storage, you could use SQLite which is an SQL compliant solution which exists within android.
If it's possible to SSH to a server via Android, you could use that to connect to mysql, because the only other solution involves having mysql binaries installed locally on your android machine, and that's not possible AS FAR AS I KNOW, on Android.
One major reason for using a webservice (e.g. written in PHP) to connect to a remote DB is that you don't want to store the database login credentials inside your app. Because otherwise it'll be easy to extract your login for that database and access and edit it in a way you might not have planned (eg. delete stuff).
Its Possible to connect mysql database .
I have done with out using php file . I have used an spring configuration file to establish an connection to the database and dao to access the data from the database.
Create an Web Application that access the Server through the Spring Framework and an Servlet .
Create an Android Client Application tat make an get / post request to the Servlet , process the results in the servlet and return the response to the Android Client Application (json format ) Process the json format reponse in the Android Client Side and use it to your application

android application that uses the same MySQL database as a PHP website

I am trying to develop an android application that will use the same MySQL database as an existing PHP website.
I have the php codes for every operation done by the web site, for example the php code of making an advanced search.
My problem is that I don't know how to implement this operations on my app.
I assume that I should use webservices, but I don't know which type.
I appreciate yourhelp guys...
PEACE.
Its Easy , You should use Ksoap2 library to implement webservices for android. Check this example creat a login page in android

Silverlight with PHP and MySQL: can I send data from the Silverlight app back to the server?

I'm creating a website using PHP and MySQL, and I'm trying to add some Silverlight stuff to the site. I need the users to be able to do stuff in the Silverlight app, and for that data to be saved in the MySQL database. I'm wondering about how I could do this...
Can I get the client side Silverlight app to log in to the server side MySQL database? Would this be a security risk? And if it's possible, how would I do it?
Or is there a better way anyone can think of? And any ideas how I'd implement it?
Thanks everyone! :)
No you should not have the app interact with your MySQL database directly. In this type of situation you will need to implement some form of web service, which exposes your data to the client. The Silverlight client code will then send requests to the web service, which runs on the server and has access to the database. Using a Microsoft technology on the server will make this a lot easier, because the IDE will do a lot of the wiring up for you, but I'm sure it could be done with PHP as well.
I would look into how to create a PHP, REST or SOAP based webservice and go from there.
Here is a video explaining how to consume the service, once you have that sorted out on the server.
http://silverlight.net/learn/videos/silverlight-videos/http-communication/

Categories