title: Text search in SQLite database - Android
body: <p>I have a database with 6 columns, 2 of them are text format. When the user enters a string I would like to search for the string in the 2 text columns and return the rows. This is the code I have come up with:</p>
  
  <pre><code>mDb.query(DATABASE_TABLE, new String[] {KEY_ROWID, KEY_TITLE, KEY_DATE}, 
                                          KEY_BODY + " LIKE '"+search_text+"%' OR "
                                        + KEY_TITLE + " LIKE '"+search_text+"%'" , 
                                          null, null, null,KEY_DATE_INT + " DESC");
  </code></pre>
  
  <p>I am reasonable sure that this translates to </p>
  
  <pre><code>Select KEY_ROWID, KEY_TITLE, KEY_DATE from DATABASE_TABLE where {(KEY_BODY LIKE 'search_text') OR (KEY_BODY LIKE 'search_text')}   
  </code></pre>
  
  <p>The problem I am having is that this only searches the first word of the columns. For example , if the text in the columns is "This is a test" and search string is "test" the query would not return the row. It will return the row if the search text is "this".</p>
  
  <p>What am I doing wrong and is there a better way to implement text search inside a SQLite database in Android.   </p>