I am dealing with http post method on Android. I have successfully send simple string pairs using HttpClient and HttpPost class with the NameValuePair as entity. However now I want to send a simple array of bytes. Unfortunately the only entities I have found for the HttpPost class are the NameValuePair and FileEntity. However my byte is not from a file. Wirting it to a file and then sending by the FileEntity seems to be pointless and stupid. How can I send this array using default HttpClient and HttpPost class??
HTTP works with character data, not binary data. The easiest may be to still use a NameValuePair, after converting the byte to a String via the android.util.Base64 class.
Ping & DNS - updated with new look and Ping home screen widget
Joined: Sep 01, 2009
Thank you. Since my data will still be base64 encoded this seems a good solution. However do I need to use the NameValuePair? I do not need to arrange the date in pairs - I just need to send the whole string...
I came upon another problem - in addition to a byte I also need to send a short. Can you also help with that problem?
Joined: Mar 22, 2005
Yes, you need to give it a name so that you can retrieve it in the servlet via getParameter - where you pass in the name.