@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    ImageView pokedexImg = (ImageView) findViewById(R.id.imageView2);
    pokedexImg.setImageResource(R.drawable.pokedex);

    mTextView = (TextView) findViewById(R.id.caughtPokemonTextView);
    mTextView.setText("Welcome To the Wonderful World of Pokemon!");
    mListView = (ListView) findViewById(R.id.pokemonListView);
    mFavoritesButton = (Button) findViewById(R.id.favoritesButton);

    Cursor cursor = null; // PokemonDatabaseHelper.getInstance(this).getPokemonList();
    mCursorAdapter =
        new SimpleCursorAdapter(
            this,
            android.R.layout.simple_list_item_1,
            cursor,
            new String[] {PokemonDatabaseHelper.COL_POKEMON_NAME},
            new int[] {android.R.id.text1, 0});
    mListView.setAdapter(mCursorAdapter);

    mListView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Cursor cursor = mCursorAdapter.getCursor();
            Intent intent = new Intent(MainActivity.this, PokemonActivity.class);
            cursor.moveToPosition(position);
            int theID =
                cursor.getInt(
                    cursor.getColumnIndex(
                        PokemonDatabaseHelper
                            .COL_ID)); // ShoppingSQLiteOpenHelper.getInstance(MainActivity.this).getIdByName(itemName);
            intent.putExtra("id", theID);
            startActivity(intent);
          }
        });

    mFavoritesButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            PokemonDatabaseHelper dbh = PokemonDatabaseHelper.getInstance(MainActivity.this);
            Cursor curse = dbh.getFavoritesList();
            mCursorAdapter.swapCursor(curse);
            mTextView.setText("My Pokemon:");
          }
        });

    PokemonDatabaseHelper.getInstance(MainActivity.this).insertAllPokemon();

    handleIntent(getIntent());
  }
  private void handleIntent(Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
      // where you do the actual database search
      String query = intent.getStringExtra(SearchManager.QUERY);

      // SELECT * FROM awesometable WHERE name = ? (or WHERE name LIKE ?)
      Cursor cursor = mPokemonDatabaseHelper.getInstance(this).searchPokemon(query);

      mCursorAdapter.swapCursor(cursor);
    }
  }