public class MyActivity extends ActionBarActivity { Menu m; final Context context=this; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_my); DatabaseTable db=new DatabaseTable(this); } @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.options_menu, menu); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { SearchManager searchManager =(SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView(); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));//Error here } return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { //return super.onOptionsItemSelected(item); switch (item.getItemId()) { case R.id.search: onSearchRequested(); return true; default: return false; } } }