如何從數據庫中保存和檢索數據。有人可以給我一點幫助,如何將Web服務與數據庫和應用程序連接起來,那麼開始的第一步是什麼。謝謝。android:如何使用web服務從sql server檢索數據
-1
A
回答
0
- 建立一個Web服務器,後者將被髮送JSON對象到你
- 然後使用HTTP調用獲得此JSON,像這樣:
public String httpGet(String url) throws IOException{ HttpGet get = new HttpGet(url); DefaultHttpClient() _httpClient = new DefaultHttpClient(); BasicHttpContext httpContext = new BasicHttpContext(); HttpResponse response=null; response = httpClient .execute(get, httpContext); StatusLine statusLine = response.getStatusLine(); int statusCode = statusLine.getStatusCode(); return EntityUtils.toString(response.getEntity()); }
更多信息,請給我留言。
0
要與遠程數據庫通信:服務器上的數據庫例如需要與API通信。他們有幾種建立API的方式:PHP,ruby。 出於安全目的,在大多數主機中禁止與遠程數據庫進行通信。
看看這個,應該有幫助http://mobiforge.com/design-development/consuming-json-services-android-apps – Panther 2014-10-28 08:29:03