0

I am populating my ListView with Volley Library from the Link

"http://192.168.***.***/allquestions/prev_ans.php/?number="+phone_number+"&&query="+query"

Suppose, the Json array for query "question change" is

[{"Name":"AAAAA","Id":"101010101","ques":"question change","Type":"class1","relatedFields":"Eduation","Name":"hshsusu","ans":"new answer 1","replyDate":"2015-09-14","replyTime":"21:05:39"}]

and the JSON array for query "newquestionforcrop" is

[{"Name":"AAAAA","Id":"101010101","ques":"question change","Type":"class1","relatedFields":"Eduation","Name":"hshsusu","ans":"new answer 1","replyDate":"2015-09-14","replyTime":"21:05:39"}]

The problem is, it only populate the list when my query has no space between them.

How should I resolve this?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Harpreet Singh
  • 543
  • 2
  • 10
  • 29
  • Suggest that you use POST request instead, then put your Json in the request's body. – BNK Sep 16 '15 at 00:26

1 Answers1

5

You URL should be encoded, because spaces can't be used in it, and must be replaced by %20.

You should use something like : query = URLEncoder.encode(query, "utf-8");

Orabîg
  • 11,718
  • 6
  • 38
  • 58
  • actually,spaces are replaced by + – Harpreet Singh Sep 15 '15 at 16:30
  • 1
    Well, both may be used, and it depends on the langage and the implementation. I'm pretty sure that both works the same on most of the servers. http://stackoverflow.com/questions/1634271/url-encoding-the-space-character-or-20 – Orabîg Sep 15 '15 at 21:51