2016-02-27 65 views
-2

我想讓IOS,Andriod &網站連接到在線數據庫,以便他們可以上傳帳戶信息,視頻和照片。我也希望他們登錄並從數據庫下載數據,並將數據顯示在手機或計算機屏幕上。應用程序如何將數據上傳到在線數據庫

到目前爲止,我可以連接到一個Android應用程序連接到EC2亞馬遜Ubuntu服務器,該服務器調用連接到RDS亞馬遜mySQL數據庫的PHP腳本,但由於某種原因,我的代碼有點搞砸了,我會問一個不同的題。

我對這一切都很陌生,網絡非常困難,我的問題是有人可以幫我解決任何問題(在這裏解釋,鏈接,視頻等!),所以我可以更好地瞭解如何獲得IOS,Andriod和網站上傳數據到數據庫,並從數據庫下載數據以顯示在手機或顯示器中!謝謝!!

回答

1

您可以使用AsyncTask將數據上傳到服務器。

這裏是你的代碼...........

public class UploadActivity extends AsyncTask<Void, Void, String> { 
Context context; 

String result; 

public UploadActivity(Context context) { 
    this.context = context; 
} 

@SuppressWarnings("static-access") 
@Override 
protected void onPreExecute() { 
    super.onPreExecute(); 


} 

@Override 
protected String doInBackground(Void... params) { 
    // TODO Auto-generated method stub 


    final List<Pair<String, String>> postParameters = new ArrayList<>(); 



    Database db= new Database(context); 
    db.open(); 
    String activity[][] = db.uploadActivity(); 
    db.close(); 
    if(activity!=null&&!activity[0].equals(null)) { 
     for (int i = 0; i < activity[0].length; i++) { 

      postParameters.add(new Pair<>("var1", activity[i][0]); 

      result = null; 


      try { 

       String response = CustomHttpClient.execute(
         URL + "UPLOAD_DATA.php", postParameters); 
       result = response.toString(); 
       result = result.replaceAll("(\r\n|\n)", ""); 

      } catch (Exception e) { 

       Log.e("log_tag_ms", "Error in http connection!!" + e.toString()); 

      } 

     } 
    } 

    return null; 
} 

protected void onPostExecute(String result) { 
    super.onPostExecute(result); 


    } } 

我的事情是有幫助...............

+0

生病的樣子進入這個但是謝謝你! – Lazar

+0

歡迎............ –

相關問題