I don’t understand: In android, I dont get the full string returned I entered into the stringbody. I have checked that the string is fully saved but when it passes to the stringbody it just breaks. In a desktop version of the same application, the results are sucessful. But in Android, a random part in the end of the string is lost. If i try to save the resulted string after it is lost, the string saves in the same spot. I dont use any accents or special chars.
Example that from a test:
First write:
This is a test bio with a random message that i’m writting on the go.
If this gets cut like i am expecting something is going to be left
out. Lets see what is going to happen.
One save saves this:
This is a test bio with a random message that i’m writting on the go.
If this gets cut like i am expecting something is going to be left out
Second save:
This is a test bio with a random message that i’m writting on the go.
If this gets cut like i am
The code is
protected void gravarPerfil() throws UnsupportedEncodingException {
MultipartEntity entity = new MultipartEntity();
StringBody sAcerca = null, sLoc = null;
DefaultHttpClient client = new DefaultHttpClient();
if (cookie != null) {
client.getCookieStore().addCookie(cookie);
}
HttpPost post = new HttpPost(address + "/dinamicas/editarPerfil");
FileBody imagebin = null;
if (imgfile != null) {
imagebin = new FileBody(imgfile);
}
Log.v("msg", acerca.getText().toString());
Here is the part where my filebody doesnt load the whole string
sAcerca = new StringBody(acerca.getText().toString());
sLoc = new StringBody(local.getText().toString());
try {
entity.addPart("acerca", sAcerca);
entity.addPart("localizacao", sLoc);
if (imgfile != null) {
entity.addPart("foto", imagebin);
}
post.setEntity(entity);
HttpResponse response = client.execute(post);
} catch (Exception e) {
e.printStackTrace();
}
Didn’t got any reasonable solution, so I applied a walk around. I discovered that the end that is removed is always between 5 – 13 chars… So I am adding 15 # to the end of the string, being then removed in the server side. It’s not pretty, but it works.