Reputation: 1061
After at least 10 hours of pouring over online resources, videos, and tutorials, I have two questions about connecting my android app with my mySQL database.
1) All the tutorials save the php files in C/WAMP/www/hello_php - for example, and so when you go to localhost/hello_php everything works.
--Where do I store my php files if I don't want to use localhost? i.e I want to use my mySQL's IP address.
--For example, the guy from this video uses this:
HttpPost httppost = new HttpPost("http://192.168.168.0.3/~tahseen@amin/php/getAllCustomers.php");
--I presume the 192.168... is the IP of his server. Where did he save the "getAllCustomers.php" file? --Note, I am using phpMyAdmin to handle the database.
2) I have already created all the code required to insert/update/delete elements from my DB. I have done this in Java using JDBC in eclipse. My understanding is that connecting my android app to my DB with JDBC is not ideal / unsafe / not recommended.
--Is all the code I wrote useless? i.e do I have to convert it all to php code?
Thanks in advance for your help
Upvotes: 0
Views: 205
Reputation: 3000
The php file in your example is stored in the home folder of user 'tahseen@amin' in the subdirectory 'php'. You can put your php file anywhere on the server as long as it is accessible for HTTP requests. Usually you would put the files in a subdirectory of the root webfolder, which is usually in /var/www/ on the server.
As far as I know Android has no support for MySQL databases, so you have to do the queries via PHP (or another programming language, as long as it is accessible as a service on your server). You can then send HTTP requests from your Android application in order to perform the database modification via the PHP scripts on the server.
Upvotes: 1