title: search database and displaying result in android (it's not working )
body: <p>This is my function in the Database class and it's closing my app when clicking on the search button:</p>
  
  <pre><code>public String search(String r) {
   String result = "";
   SQLiteDatabase db = this.getWritableDatabase();
   String query = "SELECT _Name,_City,_Job  FROM " + TABLE_Person + " WHERE _Job LIKE '" + r + "'";
   Cursor c = db.rawQuery(query, null);
   c.moveToFirst();
  
   while (!c.isAfterLast()) {
    if (c.getString(c.getColumnIndex("_Job")) == r) {
     result += c.getString(c.getColumnIndex("_Name"));
     result += c.getString(c.getColumnIndex("_City"));
     result += c.getString(c.getColumnIndex("_Job"));
    }
    c.moveToNext();
   }
  
   db.close();
  
   return result;
  }
  </code></pre>