My requirement is i want to save some data in database by using web-services. it’s working fine up to without spaces between the words.
my problem starts from here if entered text (getting text from EditText) having spaces i am getting this error.
Illegal character in path at index 103:
these are the strings from edittext : news as, news db.
this is the code
try {
HttpClient httpClient = new DefaultHttpClient();
HttpContext localContext = new BasicHttpContext();
HttpPost postRequest = new HttpPost("mwweb" +channel_token+"/" +data_src_id+
"/"+ title+"/"+details);
HttpResponse response = httpClient.execute(postRequest, localContext);
BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "UTF-8"));
String sResponse = reader.readLine();
System.out.println(" response" +sResponse);
} catch (Exception e) {
Log.e(e.getClass().getName(), e.getMessage());
}
EDIT: i got half of the solution from Android, weakwire suggetions , if i use this replaceAll(” “, “%20”) working if text have only spaces. if i use encoding working if text have special charecters, did’t get for spaces . i want the solution for both(means text having spaces and special charecters).
Url is not encoded. Also
URLEncoder.encodewill not help you unless you apply it to each argument seperatly. You can try thisor
… etc for all the arguments