title: Passing data (stored in Sqlite database), from one activity to another with onItemClickListener()
body: <p>I have phonebook app which stores new Contacts in sqlite table. I have activities to <strong>add</strong> and (list)<strong>View</strong> contacts, and they are working just fine.  </p>
  
  <p>Now, I need a Details activity which will show the details of contact cliked in the listView. I know that I should use onItemClickListener(), but everything that I have tried is not working.  </p>
  
  <p>Details Activity is containt three TextViews (name, last name, phone).<br>
  As I'm a beginner, would you be so kind telling me how to do it?  </p>
  
  <p>DisplayDataActivity.class:  </p>
  
  <pre><code>public class DisplayDataActivity extends AppCompatActivity {
  
  
  
  
  ListView listView;
  SQLiteDatabase sqLiteDatabase;
  UserDbHelper userDbHelper;
  Cursor cursor;
  ListDataAdapter listDataAdapter;
  SimpleCursorAdapter adapter;
  String name, lastName;
  TextView proba;
  
  //FROM SEARCH
  EditText Search_Last;
  String search_Last;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_display_data);
  
  
  
      Search_Last = (EditText) findViewById(R.id.searchName);
  
  
      listView = (ListView) findViewById(R.id.list_view_display);
      listDataAdapter = new ListDataAdapter(getApplicationContext(), R.layout.row_layout);
      listView.setAdapter(listDataAdapter);
  
  
      userDbHelper = new UserDbHelper(getApplicationContext());
      sqLiteDatabase = userDbHelper.getReadableDatabase();
      cursor = userDbHelper.getInformations(sqLiteDatabase);
      if (cursor.moveToFirst()) {
          do {
  
              String name, lastName, phone;
              name = cursor.getString(0);
              lastName = cursor.getString(1);
              phone = cursor.getString(2);
              DataProvider dataProvider = new DataProvider(name, lastName, phone);
              listDataAdapter.add(dataProvider);
  
  
          } while (cursor.moveToNext());
      }
  
      proba = (TextView) findViewById(R.id.text_user_name);
  
      // Opens detailed view when contact is clicked
      listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
  
              // What code goes here??
  
              Intent myIntent = new Intent(getBaseContext(), DetailView.class);
              startActivity(myIntent);
  
  
      });}  
  </code></pre>
  
  <p>DataProvider.class:  </p>
  
  <pre><code>public class DataProvider {
  
  private String name;
  private String lastName;
  private String phone;
  
  public String getLastName() {
      return lastName;
  }
  
  public void setLastName(String lastName) {
      this.lastName = lastName;
  }
  
  public String getName() {
      return name;
  }
  
  public void setName(String name) {
      this.name = name;
  }
  
  public String getPhone() { return phone; }
  
  public void setPhone(String phone) {this.phone = phone;}
  
  
  
  public DataProvider(String name, String lastName, String phone)
  {
      this.name = name;
      this.lastName = lastName;
      this.phone = phone;
  
  
  }}  
  </code></pre>
  
  <p>ListDataAdapter.class:  </p>
  
  <pre><code>public class ListDataAdapter extends ArrayAdapter {
  List list = new ArrayList();
  
  public ListDataAdapter(Context context, int resource) {
      super(context, resource);
  }
  
  static class LayoutHandler
  {
      TextView NAME, LASTNAME;
  
  }
  
  @Override
  public void add(Object object) {
      super.add(object);
      list.add(object);
  }
  
  @Override
  public int getCount() {
      return list.size();
  }
  
  @Nullable
  @Override
  public Object getItem(int position) {
      return list.get(position);
  }
  
  @NonNull
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
  
      View row = convertView;
      LayoutHandler layoutHandler;
      if(row == null)
      {
          LayoutInflater layoutInflater = (LayoutInflater) this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          row = layoutInflater.inflate(R.layout.row_layout, parent, false);
          layoutHandler = new LayoutHandler();
          layoutHandler.NAME = (TextView) row.findViewById(R.id.text_user_name);
          layoutHandler.LASTNAME = (TextView) row.findViewById(R.id.text_user_last);
          row.setTag(layoutHandler);
  
      }
      else
      {
          layoutHandler = (LayoutHandler) row.getTag();
  
  
      }
      DataProvider dataProvider = (DataProvider) this.getItem(position);
      layoutHandler.NAME.setText(dataProvider.getName());
      layoutHandler.LASTNAME.setText(dataProvider.getLastName());
  
  
      return row;
  
  
  }}  
  </code></pre>
  
  <p>DetailView.class:  </p>
  
  <pre><code>public class DetailView extends AppCompatActivity {
  
  TextView entryName, entryLastName, entryPhone;
  String strName, strLast, strPhone;
  ImageView entryPhoto;
  Cursor cursor;
  
  private DataProvider dataProvider;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_detail_view);
  
  
  
  
  
      //What code goes here ???
  
  
  
  }}
  </code></pre>