Currently my edit text view checks if the searched term contains one space as follows:
if(mSearchView.getText().toString().contains(" ")
How do I make it such that it makes sure it checks if the searchview contains 2 spaces between 3 search terms for example: "here it is"
You can use a regular expression to do that. Use code like this one:
Also make sure to check if
mSearchView.getText()
is not null - you probably will get aNullReferenceException
with a blankEditText
content.In the end you may want to create a method like this one:
just for convenience, clearance and making sure you don't bump into a
NullPointerException
.