安卓中的http请求
我想知道我们是否可以将数据库表作为http响应对象传递给android应用程序?我正在使用服务器端 mysql 数据库,现在我可以将字符串传递到客户端。因此,我在服务器端将每一列与特殊字符连接起来,并在客户端提取它以传输单行。但对于表来说这是不可能的,因为表可能有大量数据。有谁知道如何解决这个问题?
I would like to know if we can pass a database table as http response object to android application? I am using a serverside mysql database and I can pass a string to the client side right now. So I concatenated each column with a special character in server side and extracted it in client side to transfer a single row. But in case of table it is not possible, as the table may have huge amount of data. Do any one know how to fix this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一般来说,您将使用某种序列化在 Android 应用程序和服务器之间交换数据。
两种最常用的序列化格式是 XML 和 < a href="https://secure.wikimedia.org/wikipedia/en/wiki/JSON" rel="nofollow">JSON -- 我通常更喜欢 JSON,但这是个人选择的问题,我想。
您应该能够找到多种语言的 JSON 库,包括您在服务器上使用的语言和 JAVA(针对 Android 端)。
Generally speaking, you will use some kind of serialization to exchange data between your Android application and your server.
The two most used serialization formats are XML and JSON -- I generally prefer JSON, but it's a matter of personal choice, I suppose.
You should be able to find JSON libraries in several languages, including the one you are using on your server, and JAVA (for the android-side).
你想做的事情是不可能的。您需要设计您的系统,以便 Android 应用程序中不需要整个表。相反,您可以发送一条消息,其中包含找到的行数以及它们的 ID。然后,您可以根据需要发出单独的 http 请求来检索每行的内容。
What you want to do isn't possible. You need to design your system so that the whole table isn't needed in the Android application. Instead, you can send a message with the number of rows found and perhaps their ids. Then, you would make individual http requests to retrieve the contents of each row on a when needed basis.