Exclude row from EditText

I'm just wondering if I have an EditText that I turn the contents into a string, say

String queryStr = new String(searchText.getText().toString());

How can I escape the special characters from this string so that I can put it in the HttpGet method? Thank!

+5
source share
4 answers

Use java.net.URLEncoder :

java.net.URLEncoder.encode(queryStr, "UTF-8");
+7
source

Try:

TextUtils.htmlEncode(queryStr);

I think you need to do what you want.

+3
source

- :

import android.net.Uri;

...

private String getParams(String queryStr) {
    Uri.Builder builder = new Uri.Builder();
    builder.appendQueryParameter("your_parameter_key", queryStr);
    return builder.toString();
}

URL.

0

String() .

String queryStr = new String(searchText.getText().toString());

String queryStr = searchText.getText().toString();
0

All Articles