Escape encoding while parsing query parameter android

I have an uri, whose parameter is like this,

id=ahshshs+24
When I am parsing the parameter by,

String id = uri.getQueryParameter("id");

I am getting the response as

ahshshs 24

The ‘+’ is replaced by a space. I know this is because the uri gets encoded and it gets replaced. Is there a way, so as to get the value, without encoding?

Use %2B instead + symbol

so parameter should be like Dahshshs%2B24

More details Characters and symbols

While creating the URL encode it using %2B.

Refer link which states :

Space characters are replaced by `+’

A related question here, which has a lot more details on a similar topic (URL encoding)

I think that you had to encode your URL using java.net.URLEncoder.

String encodedParameter = URLEncoder.encode(paramToEncode, codification);

For example:

String encodedParameter = URLEncoder.encode("+", "UTF-8");

In this case, + will be encoded as %2B

Thanks for the responses, I had done it using UrlQuerySanitizer.
Writing the code here.
First, I extended the UrlQuerySanitizer class as

public class CustomUrlQuerySanitizer extends UrlQuerySanitizer {
    @Override
    protected void parseEntry(String parameter, String value) {
//        String unescapedParameter = unescape(parameter);
        ValueSanitizer valueSanitizer =
                getEffectiveValueSanitizer(parameter);

        if (valueSanitizer == null) {
            return;
        }
//        String unescapedValue = unescape(value);
        String sanitizedValue = valueSanitizer.sanitize(value);
        addSanitizedEntry(parameter, sanitizedValue);
    }
}

Then, parsed the url as,

String id = null;
if (uri != null) {
    UrlQuerySanitizer urlQuerySanitizer = new CustomUrlQuerySanitizer();

    urlQuerySanitizer.registerParameter("id",
            new UrlQuerySanitizer.IllegalCharacterValueSanitizer(
                    UrlQuerySanitizer.IllegalCharacterValueSanitizer.ALL_OK
            ));
    urlQuerySanitizer.parseUrl(uri.toString());
    id = urlQuerySanitizer.getValue("id");