Reputation: 1
I am doing an academical project on Electronic Voting and I need to connect Android application with my MySQL database designed in xammp. Also, I am using the eclipse program in order to do my project.
Could you help me to find the way to connect android with xammp?
Upvotes: 0
Views: 503
Reputation: 23
A sample code here
private static String loginURL = "http://xxxx/databasename/index.php";//databasename as in xampp
//note:xxxx=10.0.2.2 for emulator,
//xxxx=ip address from ipconfig cmd if android device on same network as pc.
public JSONObject loginUser(String email, String password){
// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("TAG", "SampleLogin"));
params.add(new BasicNameValuePair("email", email));
params.add(new BasicNameValuePair("password", password));
JSONObject json = jsonParser.makeHttpRequest(loginURL,"POST", params);
return json;
}
To share internet from PC itself,use windows virtual wifi router and share your pc internet to android device. For android device to access tables,Ensure you've given access rights{edit httpd-xampp.conf to "Allow from all" instead of " Require local" inside tag}
Upvotes: 0
Reputation: 383
If you need the application to connect to the database on a webserver then it might be best to create a REST service on the webserver and then access it via that.
Upvotes: 1