1

First, I'd like to let you know my experience.

PHP - medium | Android/Java - medium | JSON - low | MySQL - low

I'm trying to make an app that will be able to connect to a MySQL DB, grab a specified row, and display it in my application.

I've been doing a lot of research, but feel like I still have a lot of unanswered questions. From what I read that doing a direct connection to the database should never happen. Is this true? Next, most people suggest writing something in php to connect the app to the database. My main question is where do I put this php code? On a website or in the android app (if that's even possible)?

If anyone has experience with this, do you think I should follow this tutorial? (I don't want to buy a domain if I don't have to)

http://www.helloandroid.com/tutorials/connecting-mysql-database

2 Answers 2

1

Client side:

and android app that basically uses the defaulthttpclient in java to establish connection to a php page hosted on a website by posting data to it(httppost). and a json parser to read the retrieved data and display it.

server side: a php script on the web server which accepts post data from the client, and retrieves data from MySQL database at the server and displays it, which can be read by the client as an httpresponse.

i hope that helps.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for clearing it up. Just a question though. How would I stop anyone (except for the app) from viewing the page? Would that even be needed?
first thing that comes to my mind would be using cookies maybe. or disabling access to the folder from .htaccess.
you could also encrypt the data on the server side and decrypt it again on the client side, or for even more security, use a secret symmetric key which is in turn encrypted by a user-specific private key, and decrypt it on the client-side using that user-specific key. that way, even if a single private key is compromised, you can block that particular key. it depends on your security needs whether you need to go this far, of course. you can look into openssl_seal() and openPGP to see how to implement this.
0

Create a web service to pull objects that contain data from your database. A WCF Service is a good choice.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.