0

Using a Flask backend to to return a string from a url with Python. I am returning a string

return "error"

The only thing displayed when visiting the site is "error".

I am trying to make an if statement using Android Studio that checks if the string "error" is returned:

@Override
public void onResponse(@NonNull Call call, @NonNull Response response) throws IOException {
    String s = response.body().string();
    Log.i("existsCheck", s);

    if(s == "error") {
        Log.i("existsCheck", "match");
    } else {
        Log.i("existsCheck", "nope");
    }
}

This outputs:

error
nope

Why doesn't the if statement output match when "s" equals error?

Mark Rotteveel
  • 90,369
  • 161
  • 124
  • 175

1 Answers1

0
if ( s.equals("error"))
Laurel
  • 5,771
  • 12
  • 29
  • 54