如何从数据库中保存和检索数据。有人可以给我一点帮助,如何将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