This looks like it will work. Since you are just checking one character, no need for substring, try this:

```Java
for(int i = 0; i < battleTag.length(); i++) {
    if (battleTag.charAt(i) == " ")
        //Toast, adapter.clear(), return
```