Q:

contentEquals not working

I am trying to compare two strings.
s1 - user input (String) and
s2 - dbHelper.getdata(s1) (String), search if the text in s1 is in the database

 My code works fine BUT I noticed something strange :

Not adding the word/ user input (s1) in listview even if the word is in the database -- (I don't want this one) BUT whenever the word is not in my database it gives a toast which I want. (I use this code).  

public void viewWord(View view) {
        s1 = text.getText().toString();
        s2 = dbHelper.getData(s1);
        newData = text.getText().toString();
        s1.trim();
        s2.trim();

        if (s1.isEmpty()) {
          Toast.makeText(getApplicationContext(), "Tap tiles to form a word.", Toast.LENGTH_SHORT).show();
        }

        //check if s1 == s2 
        if (s1.contentEquals(s2)) {
          Toast.makeText(getApplicationContext(), "Word Found", Toast.LENGTH_SHORT).show();

            if (!myList.contains(newData)) { // No duplicate entry

              //display score
              calculate();
              adapter = (ArrayAdapter) wordList.getAdapter();
              adapter.add((String) newData);
              adapter.notifyDataSetChanged();

            }
        } else {

              //check if s1 is not equal to s2
              Toast.makeText(getApplicationContext(), "Word not found. Try a new one.", Toast.LENGTH_SHORT).show();
          }

2. Adding the word when i use the code below, which I want BUT closing the app when the word is not in the database. 

public void viewWord(View view) {
    s1 = text.getText().toString();
    s2 = dbHelper.getData(s1);
    newData = text.getText().toString();
    s1.trim();
    s2.trim();

    if (s1.isEmpty()) {
      Toast.makeText(getApplicationContext(), "Tap tiles to form a word.", Toast.LENGTH_SHORT).show();
    }

        //check if s1 is not equal to s2 

        if (!s1.contentEquals(s2)) {
          Toast.makeText(getApplicationContext(), "Word Found", Toast.LENGTH_SHORT).show();

          if (!myList.contains(newData)) { // No duplicate entry
            //display score
            calculate();
          adapter = (ArrayAdapter) wordList.getAdapter();
          adapter.add((String) newData);
          adapter.notifyDataSetChanged();

          }
         } else {

              //check if s1 equal to s2

              Toast.makeText(getApplicationContext(), "Word not found. Try a new one.", Toast.LENGTH_SHORT).show();
            }

I WANT IT THIS WAY: 
If the user input (s1) is in the database (s2) then add user input to Listview. Its like:
if(s1==s2){ //add user input to listview)}

If the user input (s1) is NOT in the database then simply show toast, NOT closing the app like what I am into right now. its like:
if(s1!=s2){ //show toast )}

DBHelper

public String getData(String word)
    {
        SQLiteDatabase db = helper.getWritableDatabase();
        String[] columns={DBHelper.WORD, DBHelper.SCORE};
        Cursor cursor=db.query(DBHelper.TABLE_NAME, columns, DBHelper.WORD+ "= '"+word+"'", null, null, null, null);
        StringBuffer buffer = new StringBuffer();
        while(cursor.moveToNext())
        {
            int index1 = cursor.getColumnIndex(DBHelper.WORD);
            int index2 = cursor.getColumnIndex(DBHelper.SCORE);
            String words = cursor.getString(index1);
            String score = cursor.getString(index2);
            buffer.append(score +"\n");
        }
        return buffer.toString();
    }

I am using Android Studio and I have no idea about this so I am asking. I've done .contains, .equal but the result is still the same. Badly need help.

A:

Adapter is not responsible for your data, it is responsible for mapping data to ui elements. So you need to put your data to DB and that would change your Cursor automatically, than you will get your list updated. Use CursorAdapter or ContentObserver + ArrayAdpter to achieve this functionality. 

