简体   繁体   English

Android中的http请求

[英]http request in android

I would like to know if we can pass a database table as http response object to android application? 我想知道是否可以将数据库表作为http响应对象传递给android应用程序? I am using a serverside mysql database and I can pass a string to the client side right now. 我正在使用服务器端mysql数据库,现在可以将字符串传递给客户端。 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? 有人知道如何解决此问题吗?

Generally speaking, you will use some kind of serialization to exchange data between your Android application and your server. 一般来说,您将使用某种序列化在Android应用程序和服务器之间交换数据。

The two most used serialization formats are XML and JSON -- I generally prefer JSON, but it's a matter of personal choice, I suppose . 两种最常用的序列化格式是XMLJSON- 我通常更喜欢JSON,但是我想这是个人选择的问题

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) . 您应该能够找到几种语言的JSON库,包括您在服务器上使用的库和JAVA (用于android端)

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. 您需要设计系统,以便在Android应用程序中不需要整个表。 Instead, you can send a message with the number of rows found and perhaps their ids. 相反,您可以发送一条消息,其中包含找到的行数及其ID。 Then, you would make individual http requests to retrieve the contents of each row on a when needed basis. 然后,您将发出单独的http请求,以在需要时检索每行的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM