I have a phpmyadmin setup with dream host. Lets say for instance I wanted to retrieve user names and passwords from the database from android, how would I go about doing that? To access my database, I need the username and password for the database, so how can I connect through android without people being able to view the source code of my app and see the database credentials?
EDIT: A big misunderstanding I have is, where do I store the php webservice file? Not on the device, right?
You can connect directly to MySQL, but is not a good practice, specially for production apps. My advice is to use a Web service that will facilitate the connection.
Web services are services that are made available from a business's Web server for Web users or other Web-connected programs, in this case, your Android app.
Here is a great tutorial to get you started Android, MySQL and PHP
Make a class to make an HTTP request to the server. For example (I am using JSON parsing to get the values):
In your MainActivity, make an object with the class JsonFunctions and pass the URL from where you want to get the data as an argument. For example:
And then finally read the JSON tags and store the values in an ArrayList. Later, show them in a ListView if you want.
You might find an answer here Can an Android App connect directly to an online mysql database