title: TextView is not showing the string retrieved from database
body: <p>My program has an activity and a database class. there is a button for retrieving data from database.i meant to show the string in the <code>textView</code>. but it is not getting.</p>
  
  <p><strong>FirstActivity.java</strong></p>
  
  <pre><code>package example.showevent1;
  
      import java.util.Calendar;
  
      import android.os.Bundle;
      import android.app.DatePickerDialog;
      import android.app.Dialog;
      import android.content.ContentValues;
      import android.content.Context;
      import android.database.Cursor;
      import android.database.sqlite.SQLiteDatabase;
      import android.support.v4.app.*;
      import android.view.View;
      import android.view.inputmethod.InputMethodManager;
      import android.widget.AdapterView;
      import android.widget.ArrayAdapter;
      import android.widget.Button;
      import android.widget.DatePicker;
      import android.widget.EditText;
      import android.widget.Spinner;
      import android.widget.TextView;
      import android.widget.AdapterView.OnItemSelectedListener;
  
      public class FirstActivity extends FragmentActivity implements OnItemSelectedListener {
          /** Called when the activity is first created. */
  
          classdbOpenHelper eventsData;
          classdbOpenHelper eventsData1;
  
           TextView userSelection;
           Button okButton;
           Button addButton;
  
           Button change_date_but;
           TextView date;
           TextView show;
           EditText edittext;
            public static final int Date_dialog_id = 1;
            private int mYear;
            private int mMonth;
            private int mDay;
  
          private static final String[] items={"Yalahanka","Rajai nagar","Sivaji Nagar","Koramangala","RT Nagar", "Banashankari","Yashwanthpura","Hebbal"};
  
  
  
          @Override
          public void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_first);
               okButton = (Button)findViewById(R.id.button2);
               addButton = (Button)findViewById(R.id.button3);
  
               change_date_but = (Button)findViewById(R.id.button1);
               date = (TextView)findViewById(R.id.textView2);//KEY_DATE
               userSelection=(TextView)findViewById(R.id.textView1);//KEY_DESC
               edittext=(EditText)findViewById(R.id.editText1);//KEY_EVENT
               show=(TextView)findViewById(R.id.textView5);
  
               Spinner my_spin=(Spinner)findViewById(R.id.spinner1);
              my_spin.setOnItemSelectedListener(this);
              ArrayAdapter aa=new ArrayAdapter(this, android.R.layout.simple_spinner_item,items);
              aa.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
              my_spin.setAdapter(aa);
  
              okButton.setOnClickListener(new clicker());
              addButton.setOnClickListener(new getclicker());
  
              eventsData = new classdbOpenHelper(this);
  
              change_date_but.setOnClickListener(new View.OnClickListener() {
  
  
  
                         @Override
                         public void onClick(View v) {
                           DatePickerDialog DPD = new DatePickerDialog(
                         FirstActivity.this, mDateSetListener, mYear, mMonth,mDay);
                                      DPD.show();
                     }
                        });
              final Calendar c = Calendar.getInstance();
                    mYear = c.get(Calendar.YEAR);
                    mMonth = c.get(Calendar.MONTH);
                    mDay = c.get(Calendar.DAY_OF_MONTH);
  
                    updateDisplay();
          }
           @Override
               @Deprecated
  
               protected void onPrepareDialog(int id, Dialog dialog) {
                // TODO Auto-generated method stub
             super.onPrepareDialog(id, dialog);
  
                ((DatePickerDialog) dialog).updateDate(mYear, mMonth, mDay);
  
               }
  
               private DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() {
  
             public void onDateSet(DatePicker view, int year, int monthOfYear,
                  int dayOfMonth) {
                 mYear = year;
                 mMonth = monthOfYear;
             mDay = dayOfMonth;
                 updateDisplay();
                }
               };
  
               private void updateDisplay() {
             // TODO Auto-generated method stub
                date.setText(new StringBuilder()
                  // Month is 0 based so add 1
               .append(mMonth + 1).append("-").append(mDay).append("-")
                  .append(mYear));
               }
  
  
  
  
  
  
  
          @Override
          public void onItemSelected(AdapterView&lt;?&gt; arg0, View arg1, int pos, long arg3) {
              userSelection.setText(items[pos]);
          }
          @Override
          public void onNothingSelected(AdapterView&lt;?&gt; arg0) {
              // TODO Auto-generated method stub
              userSelection.setText("");
          }
  
  
  
          class clicker implements Button.OnClickListener {
              public void onClick(View v) {
                  String datevalue = date.getText().toString();
                  String Userselectvalue = userSelection.getText().toString();
                  String Userevent = edittext.getText().toString();
                  SQLiteDatabase  db = eventsData.getWritableDatabase();
  
                  ContentValues cv = new ContentValues();
                  cv.put(classdbOpenHelper.KEY_DESC, Userselectvalue);
                  cv.put(classdbOpenHelper.KEY_EVENT, Userevent);
                  cv.put(classdbOpenHelper.KEY_DATE,datevalue);
                  db.insert(classdbOpenHelper.DATABASE_TABLE, null, cv);
                  db.close();
              }
  
  
          public void onDestroy() {
            eventsData.close();
          }
  
      }
          class getclicker implements Button.OnClickListener {
              public void onClick(View v) {
                  String datevalue = date.getText().toString();
                  String Userselectvalue = userSelection.getText().toString();
  
                  String showevent = eventsData.getContact(datevalue,Userselectvalue);
                  show.setText(showevent);
              }
              public void onDestroy() {
                  eventsData.close();
                }
  
          }
  
      }
  </code></pre>
  
  <p><strong>classdbOpenHelper.java</strong></p>
  
  <pre><code>package example.showevent1;
  
  import android.content.Context;
  import android.database.Cursor;
  import android.database.sqlite.SQLiteDatabase;
  import android.database.sqlite.SQLiteOpenHelper;
  import android.widget.TextView;
  
  
  public class classdbOpenHelper extends SQLiteOpenHelper {
  
      public static final String KEY_ROWID = "id";
      public static final String KEY_DESC = "countdesc";
      public static final String KEY_EVENT = "countevent";
      public static final String KEY_DATE = "countdate";
  
      public static final String DATABASE_NAME= "countdb";
      public static final String DATABASE_TABLE = "countable";
      public static final int DATABASE_VERSION = 1;
  
  
      public classdbOpenHelper(Context context) {
          super(context, DATABASE_NAME, null, DATABASE_VERSION);
          // TODO Auto-generated constructor stub
      }
  
  
      @Override
      public void onCreate(SQLiteDatabase db) {
         /* db.execSQL("CREATE TABLE " + DATABASE_TABLE + " (" +
          KEY_ROWID + " INTEGER PRIMARY KEY AUTOINCREMENT " +
          //KEY_COUNTED + " INTEGER " +
          KEY_DESC + " TEXT NOT NULL " +
          KEY_DATE + " TEXT NOT NULL);"
                  ); */
          String CREATE_CONTACTS_TABLE = "CREATE TABLE " + DATABASE_TABLE + "("
                  + KEY_ROWID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + KEY_DESC + " TEXT, " + KEY_EVENT + " TEXT, " + KEY_DATE + " TEXT " + ")";
          db.execSQL(CREATE_CONTACTS_TABLE);
      }
  
  
      @Override
      public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
          // TODO Auto-generated method stub
          db.execSQL("DROP TABLE IF EXITS " + DATABASE_TABLE);
          onCreate(db);
  
      }
  
      public String getContact(String datevalue,String Userselectvalue) 
      {
           String place = null;
        String selection = classdbOpenHelper.KEY_DESC + " = 'Userselectvalue'"  
             +" AND " + classdbOpenHelper.KEY_DATE + " = 'datevalue'";
        SQLiteDatabase db = this.getReadableDatabase(); 
        Cursor cursor = db.query(classdbOpenHelper.DATABASE_TABLE, 
             new String[] {classdbOpenHelper.KEY_EVENT }, selection, 
             null, null, null, null);
        if (cursor .getCount() &gt; 0) {
             cursor .moveToFirst();
             do {
                    place = cursor.getString(0);
             } while (cursor.moveToNext());
         }
        cursor.close();
      return place;  
      }
  }
  </code></pre>
  
  <blockquote>
    <p>activity_first.xml</p>
  </blockquote>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:paddingBottom="@dimen/activity_vertical_margin"
      android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      android:background="@color/color_1"
      tools:context=".FirstActivity" &gt;
  
      &lt;Button
          android:id="@+id/button1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignLeft="@+id/spinner1"
          android:layout_below="@+id/spinner1"
          android:layout_marginTop="28dp"
          android:background="#ffff99"
          android:text="@string/dt"
          android:textColor="#b22924" /&gt;
  
      &lt;TextView
          android:id="@+id/textView1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignLeft="@+id/spinner1"
          android:layout_alignParentTop="true"
          android:layout_marginTop="31dp"
          android:text="@string/select"
          android:textAlignment="gravity"
          android:textColor="#b22924"
          android:textSize="20sp"
          android:textStyle="bold" /&gt;
  
      &lt;Spinner
          android:id="@+id/spinner1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentLeft="true"
          android:layout_below="@+id/textView1"
          android:layout_marginTop="36dp"
          android:background="#ffff99"
          android:textColor="#b22924" 
          android:fadingEdge=""/&gt;
  
      &lt;EditText
          android:id="@+id/editText1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignLeft="@+id/button1"
          android:layout_below="@+id/button1"
          android:layout_marginTop="40dp"
          android:background="#ffff99"
          android:ems="10" /&gt;
  
      &lt;Button
          android:id="@+id/button2"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignBaseline="@+id/editText1"
          android:layout_alignBottom="@+id/editText1"
          android:layout_alignParentRight="true"
          android:text="@string/_add" /&gt;
  
      &lt;TextView
          android:id="@+id/textView2"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignBottom="@+id/button1"
          android:layout_alignParentRight="true"
          android:background="#ffff99"
          android:text="Medium Text"
          android:textAppearance="?android:attr/textAppearanceLarge" /&gt;
  
      &lt;TextView
          android:id="@+id/textView3"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignLeft="@+id/textView1"
          android:layout_alignParentTop="true"
          android:text="Select A Place" /&gt;
  
      &lt;TextView
          android:id="@+id/textView4"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignRight="@+id/button1"
          android:layout_alignTop="@+id/button2"
          android:text="Add Event" /&gt;
  
      &lt;Button
          android:id="@+id/button3"
          style="?android:attr/buttonStyleSmall"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignLeft="@+id/editText1"
          android:layout_below="@+id/button2"
          android:layout_marginTop="27dp"
          android:text="Show Event" /&gt;
  
      &lt;TextView
          android:id="@+id/textView5"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_alignParentBottom="true"
          android:layout_centerHorizontal="true"
          android:layout_marginBottom="22dp"
          android:background="#ffff99"
          android:text="" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <blockquote>
    <p>strings.xml</p>
  </blockquote>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;resources xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  
      &lt;string name="app_name"&gt;EVENTS&lt;/string&gt;
      &lt;string name="action_settings"&gt;Settings&lt;/string&gt;
      &lt;string name="select"&gt;SELECT A PLACE&lt;/string&gt;
      &lt;color name="color_1"&gt;#ffcccccc&lt;/color&gt;
      &lt;string name="dt"&gt;date&lt;/string&gt;
      &lt;string name="_add"&gt;Add&lt;/string&gt;
  
  
  &lt;/resources&gt;
  </code></pre>