title: android - how to display data from one activity to another activity by query in SQLite DataBase table? - Stack Overflow
body: <p>I have done following coding for retrieving data's from database and want to display in the Edit Text view to another activity. The following code is for the fetching data..</p>
  
  <pre><code>   String fetch_data(int id) {
      SQLiteDatabase sq = this.getReadableDatabase();
  
      String q = "SELECT "+TAB_NAME+" FROM "+TABLE_NAME+" WHERE "+TAB_ID+" = "+id;
  
      Cursor c = sq.rawQuery(q, null);
  
      String s = "";
      c.moveToFirst();
      if (c.moveToFirst()) {
          s = c.getString(c.getColumnIndex(TAB_NAME+""));
      }
  
      return s;
  
  }
  </code></pre>
  
  <p>The following code is for the showing the data in this activity..</p>
  
  <pre><code>t1 = (EditText) findViewById(R.id.editText);
  
      final MyDBFunction obj = new MyDBFunction(getApplicationContext());
      int req_pos = getIntent().getIntExtra("MyKEY",999);
      t1.setText(obj.fetch_data(req_pos+1));
      t1.setSelection(t1.getText().length());
  </code></pre>
  
  <p>and this code is from the activity where i am trying to get the data..</p>
  
  <pre><code>l = (ListView)findViewById(R.id.listView);
  
  
      MyDBFunction mf = new MyDBFunction(getApplicationContext());
  
      final String[] data = mf.broadData();
  
      l.setAdapter(new ArrayAdapter(getApplicationContext(),R.layout.lvlayout,R.id.text1,data));
  
      l.setOnItemClickListener(new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
              Toast.makeText(getApplicationContext(),"Clicked On "+data[position],Toast.LENGTH_SHORT).show();
          Intent i = new Intent(getApplicationContext(),ShowInfo.class);
              i.putExtra("MyKEY",position);
              startActivity(i);
          }
      });
  </code></pre>
  
  <p>but i can't get the data where is the problem???</p>