title: eroors in sqlite database occourd in retriving the data from the table in android
body: <p>my DataHandler activity code is</p>
  
  <pre><code>import android.content.ContentValues;
  import android.content.Context;
  import android.database.Cursor;
  import android.database.SQLException;
  import android.database.sqlite.SQLiteDatabase;
  import android.database.sqlite.SQLiteOpenHelper;
  
  public class DataHandlerDairy {
  
  public static final String DATE = "date";
  public static final String DAIRY = "dairy";
  private static final String DATA_BASE_NAME = "mydairy";
  private static final String TABLE_NAME = "table_dairy";
  private static final int DATABASE_VERSION = 1;
  private static final String TABLE_CREATE="create table table_diary       (date text primary key," + "dairy text not null);";
  
  DataBaseHelper1 dbhelper1;
  Context ct;
  SQLiteDatabase db;
  
  public DataHandlerDairy(Context ct)
  {
      this.ct=ct;
      dbhelper1 = new DataBaseHelper1(ct);
  
  }
  
  private static class DataBaseHelper1 extends SQLiteOpenHelper
  {
  
  public DataBaseHelper1(Context ct)
  {
      super(ct,DATA_BASE_NAME,null, DATABASE_VERSION);
  }
  
  
      @Override
  public void onCreate(SQLiteDatabase db) {
      // TODO Auto-generated method stub
      try
      {
          db.execSQL(TABLE_CREATE);
      }
      catch(SQLException e)
      {
          e.printStackTrace();
      }
      }
  
  
  
  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
  
      db.execSQL("DROP TABLE IF EXISTS table_dairy ");
      onCreate(db);
  }
  
  } 
  
  public DataHandlerDairy open()
  {
  db = dbhelper1.getWritableDatabase();
  return this;
  }
  
  public void close()
  {
      dbhelper1.close();
  }
  
  public long insertData(String date,String dairy)
  {
      ContentValues content = new ContentValues();
      content.put(DATE, date);
      content.put(DAIRY, dairy);
      return db.insertOrThrow(TABLE_NAME, null, content);
  }
  
  public Cursor returnData(String date1) throws SQLException
  {
      Cursor c = db.query(true, TABLE_NAME, new String[] { DATE, DAIRY}, DATE + "=" + date1, null, null, null, null, null);
      if(c!=null)
      {
          c.moveToFirst();
      }
      return c;
  }
  }
  </code></pre>
  
  <p>And when i try to use the save operation ie <code>insertData()</code> method in the DataHandler Activity. And storing the date I have got the date from another activity using Intents.</p>
  
  <p>The code for Saving data into database is</p>
  
  <pre><code>    import android.os.Bundle;
  import android.app.Activity;
  import android.content.Intent;
  import android.view.Menu;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.EditText;
  import android.widget.ImageButton;
  import android.widget.Toast;
  
  public class Write_Dairy extends Activity {
  
  EditText et1;
  ImageButton correct,wrong;
  DataHandlerDairy handler2;
  String getdate;
  
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_write__dairy);
  
  
  
  
      et1 = (EditText) findViewById(R.id.writediary);
      correct=(ImageButton) findViewById(R.id.correct1);
      wrong=(ImageButton) findViewById(R.id.wrong1);
  
  
      Bundle bundle = getIntent().getExtras();
      getdate = bundle.getString("message");
  
  
      correct.setOnClickListener(new OnClickListener() {
  
  
          @Override
          public void onClick(View arg0) {
              // TODO Auto-generated method stub
  
  
              String getdairy = et1.getText().toString();
              handler2 = new DataHandlerDairy(getBaseContext());
              handler2.open();
              long id = handler2.insertData(getdate,getdairy);
              Toast.makeText(getBaseContext(), "your dairy is saved successfully", Toast.LENGTH_LONG).show();
              handler2.close();
  
              Intent ijk = new Intent(Write_Dairy.this,PickYourDate.class);
              startActivity(ijk);
  
          }
      });
  
      wrong.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View arg0) {
              Toast.makeText(getBaseContext(), "please write your dairy again", Toast.LENGTH_LONG).show();
              et1.setText("");
  
          }
      });
  
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.activity_write__dairy, menu);
      return true;
  }
  
  }
  </code></pre>
  
  <p>and for retriving the data i have used the date as primary key which i used it as string in both sql and java. the code for retriveing the data is </p>
  
  <pre><code>import android.os.Bundle;
  import android.app.Activity;
  import android.content.Intent;
  import android.database.Cursor;
  import android.graphics.Typeface;
  import android.view.Menu;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  import android.widget.ImageButton;
  import android.widget.TextView;
  
  public class Read_Dairy extends Activity {
  
  
  String date1;
  TextView tv1;
  ImageButton imgb1;
  Button bt1;
  DataHandlerDairy handler3;
  String getdata=" ";
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_read__dairy);
  
  
  
      tv1=(TextView) findViewById(R.id.readme);
      imgb1=(ImageButton) findViewById(R.id.tick);
      bt1=(Button) findViewById(R.id.ready);
  
      Bundle bundle = getIntent().getExtras();
      date1 = bundle.getString("kanna");
  
  
  
      bt1.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View v) {
              // TODO Auto-generated method stub
              handler3 = new DataHandlerDairy(getBaseContext());
              handler3.open();
              Cursor c = handler3.returnData(date1);
              if(c.moveToFirst())
              {
                  do
                  {
                  getdata=c.getString(1);
  
                  }while(c.moveToNext());             
                  }
              handler3.close();
  
              if(getdata==null)
              {
                  tv1.setText("no data exists for this date");
              }
              else
              {
              tv1.setText(c.getString(1));
              }
  
          }
  
      });
  
  
      imgb1.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View v) {
              // TODO Auto-generated method stub
  
              Intent ks = new Intent(Read_Dairy.this,PickYourDate.class);
              startActivity(ks);
  
          }
      });
  
      Typeface font = Typeface.createFromAsset(getAssets(), "Strato-linked.ttf");
      tv1.setTypeface(font);
  
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.activity_read__dairy, menu);
      return true;
  }
  
  }
  </code></pre>
  
  <p>The stack trace while i tried to store data is</p>
  
  <blockquote>
  <pre><code>E/SQLiteLog(16724): (1) no such table: table_dairy
   D/AndroidRuntime(16724): Shutting down VM
   E/AndroidRuntime(16724): FATAL EXCEPTION: main
   E/AndroidRuntime(16724): Process: simple.smile.my_dairy, PID: 16724
   E/AndroidRuntime(16724): android.database.sqlite.SQLiteException: no such table: table_dairy (code 1): , while compiling: INSERT INTO table_dairy(date,dairy) VALUES (?,?)
   E/AndroidRuntime(16724):   at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
   E/AndroidRuntime(16724):   at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
   E/AndroidRuntime(16724):   at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
   E/AndroidRuntime(16724):   at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
   E/AndroidRuntime(16724):   at android.database.sqlite.SQLiteProgram.&lt;init&gt;(SQLiteProgram.java:58)
   E/AndroidRuntime(16724):   at android.database.sqlite.SQLiteStatement.&lt;init&gt;(SQLiteStatement.java:31)
   E/AndroidRuntime(16724):   at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1469)
   E/AndroidRuntime(16724):   at android.database.sqlite.SQLiteDatabase.insertOrThrow(SQLiteDatabase.java:1367)
   E/AndroidRuntime(16724):   at simple.smile.my_dairy.DataHandlerDairy.insertData(DataHandlerDairy.java:79)
   E/AndroidRuntime(16724):   at simple.smile.my_dairy.Write_Dairy$1.onClick(Write_Dairy.java:48)
   E/AndroidRuntime(16724):   at android.view.View.performClick(View.java:4832)
   E/AndroidRuntime(16724):   at android.view.View$PerformClick.run(View.java:19839)
   E/AndroidRuntime(16724):   at android.os.Handler.handleCallback(Handler.java:739)
   E/AndroidRuntime(16724):   at android.os.Handler.dispatchMessage(Handler.java:95)
   E/AndroidRuntime(16724):   at android.os.Looper.loop(Looper.java:211)
   E/AndroidRuntime(16724):   at android.app.ActivityThread.main(ActivityThread.java:5315)
   E/AndroidRuntime(16724):   at java.lang.reflect.Method.invoke(Native Method)
   E/AndroidRuntime(16724):   at java.lang.reflect.Method.invoke(Method.java:372)
   AndroidRuntime(16724):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:941)
  E/AndroidRuntime(16724):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:736)
  </code></pre>
  </blockquote>
  
  <p>Will anyone please tell what is the mistake i have done and how can the error be solved.
  Thanks in advance.</p>