0

i got a problem which i tried hard to solve with searching with google because will be a simple solution.

I want to open the following url:

http://<<IP>>/query.html?sql="select * from ADAnreden"

To do this, i write this url in a string to open it with HttpGet...

String url = "http://"+ip+"/query.html?sql=\"select * from ADAnreden\"";

So i escaped the " infront of select and after ADAnreden. But the problem is that the following error is comming up:

Illegal character in query at index 36. 

This is the equals sign. So how can i escape the = ? The backslash is not working.

Thanks for help

Shadwell
  • 34,314
  • 14
  • 94
  • 99
Bolic
  • 705
  • 2
  • 12
  • 30

2 Answers2

3

The issue is the escaping for the URL, not for Java. Spaces are not valid in URLs. See this answer for more about URL encoding in Android.

Community
  • 1
  • 1
isaach1000
  • 1,819
  • 1
  • 13
  • 18
2

you must encode the query before using it as URL, see URLEncoder.encode(query);

Mohammad Ersan
  • 12,304
  • 8
  • 54
  • 77