My json file contains white space such as 1522663136Vehicle and Bike Procurement Notice 1.PDF
. In browswer, by default %20 is added. But while using this file in android project, I can't escape white space. My json output is as follow.
"heading": "Notice",
"content": "Tender Notice",
"img": "1522663136Vehicle and Bike Procurement Notice 1.PDF"
And I am trying to replace white space using replaceALL
String heading = hit.getString("heading");
String content = hit.getString("content");
String pdf = hit.getString("img");
pdf.replaceAll(" ","%20");
String link = "fitandfineindustries.com/images/notices/"+pdf;
mExampleList.add(new ExampleItem(heading, date, content, click, link));
But it doesn't work
In Java, strings are immutable, so replaceAll returns a new string rather than changing the existing one. Try this:
pdf = pdf.replaceAll(" ","%20");