I’m actually working on an Android application, which accepts a keyword to search in a MySQL database (through a web service which is written in PHP).
I have a problem here:
When I enter a keyword, say, "buffet", the result is returned just fine, but if I have a space after that, i.e. "buffet ", it will turn out that no match is found.
I’m kind of confused because I actually use trim() for the keyword in the PHP script of the API, but the keyword here is still passed with a space behind it. So I’m looking for some simple way to remove the space after the keyword passed in the search field, if there is any.
Please help me with this, and thanks.
As strings are immutable,
String.trim()will not change the content of the string itself. Make sure to assign the result: