我正在做一個關於電子投票的大學項目,我需要將Android應用程序與我在xammp中設計的MySQL數據庫連接起來。另外,我正在使用eclipse程序來完成我的項目。將Android與數據庫連接
你能幫我找到連接android與xammp的方式嗎?
我正在做一個關於電子投票的大學項目,我需要將Android應用程序與我在xammp中設計的MySQL數據庫連接起來。另外,我正在使用eclipse程序來完成我的項目。將Android與數據庫連接
你能幫我找到連接android與xammp的方式嗎?
如果您需要應用程序連接到Web服務器上的數據庫,那麼最好在Web服務器上創建REST服務,然後通過它訪問它。
這裏
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;
}
從PC本身共享上網的示例代碼,使用Windows虛擬無線路由器和分享您的PC互聯網到Android設備。 對於android設備訪問表,請確保您已授予訪問權限{編輯httpd-xampp.conf爲「允許所有」而不是「需要本地」內部標籤}
請問您能解釋一下嗎? – nikoua 2011-04-02 14:27:32