I have stored a couple of urls in strings.xml
file. I want to store them without encoding them (as raw text), but strings.xml
throws error for =
and &
.
For example:
http://www.example.org/index.php?p=616687&ac=some_q
If I store the link as it is, it will throw the error:
The reference to entity "ac" must end with the ';' delimiter.
However, if I replace the &
with %26
:
http://www.example.org/index.php?p=616687%26ac=some_q
while this works without any error, this doesn't open the correct page in the browser.
Is there any way I can store the links in strings.xml
as it is without formatting or uri encoding them?
You cannot use
&
directly, because XML document is expected to be well-formed and the problem is with&
character itself. For XML/HTML you would have to use&
entity (or&
), but for URL use URL encoding and replace&
it with%26
(as you did) which should simply work as browsers do understand such things as they simply have to.You could Base64 encode and decode your URL Strings with http://developer.android.com/reference/android/util/Base64.html