App gets force closed when going to this activity. I actually noticed that if i remove the cursor part the activity doesn't crash. Help would be appreciated.
public class SearchResults extends ListActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.searchresults);
Database myDbHelper = new Database(null);
myDbHelper = new Database(this);
try {
myDbHelper.createDataBase();
} catch (IOException ioe) {
throw new Error("Unable to create database");
}
try {
}catch(SQLException sqle){
throw sqle;
}
// Get the intent, verify the action and get the query
Intent intent = getIntent();
String query = intent.getStringExtra(SearchManager.QUERY);
SQLiteDatabase myDb = myDbHelper.getReadableDatabase();
String q = "SELECT BookTitle, _ISBN FROM Books WHERE BookTitle LIKE" + query;
Cursor c = myDb.rawQuery(q, null);
startManagingCursor(c);
// the desired columns to be bound
String[] columns = new String[] { "Books._ISBN", "Books.BookTitle" };
// the XML defined views which the data will be bound to
int[] to = new int[] { R.id.ISBN_entry, R.id.Title_entry };
SimpleCursorAdapter mAdapter = new SimpleCursorAdapter(this, R.layout.listlayout, c, columns, to);
this.setListAdapter(mAdapter);
}
}