title: Error:no such table: When Inserting Data in Sqlite Database
body: <p>I am trying to insert data into <code>sqlite Database</code>. I am following <code>Youtube</code> Tutorial to do this task.</p>
  
  <p>I have written the following code and it successfully creates <code>Sqlite Database file</code> but when i try to insert data it gives me error messages.</p>
  
  <p>I have written the following code. Kindly guide me what i am doing wrong here.</p>
  
  <pre><code>public class DatabaseHelper extends SQLiteOpenHelper {
  
      public static final String DATABASE_NAME="ep";  
      public static final String TABLE_NAME= "transactionsHistory";
      public static final String ID= "ID";
      public static final String MESSAGE= "MESSAGE";
      public static final String CREATE_TABLE= "create table "+ TABLE_NAME + " ( "+ID+" INTEGER PRIMARY KEY AUTO INCREMENT, "+MESSAGE+" TEXT)";
      public static final String DROP_TABLE= "DROP TABLE IF EXISTS"+ TABLE_NAME; 
      private Context context;
  
  
      public DatabaseHelper(Context context) {
          super(context, DATABASE_NAME, null , 1);
          SQLiteDatabase db= this.getWritableDatabase();
          this.context= context; 
      }
  
      @Override
      public void onCreate(SQLiteDatabase db) {
          try {
              db.execSQL(CREATE_TABLE);
          } catch (SQLException e) {                  
              e.printStackTrace();        
          }
    }
  
  public void insertData(DatabaseHelper dbHelper , String Message){
  
      SQLiteDatabase db= dbHelper.getWritableDatabase();
  
      ContentValues contentValues= new ContentValues();
      contentValues.put(MESSAGE, Message);
      db.insert(TABLE_NAME, null, contentValues);
  
      Log.d("Insert Successfull ", "Value : "+Message + " :Data Inserted");
  }
  </code></pre>
  
  <p><strong>Calling DB Class in Activity</strong></p>
  
  <pre><code>public class SuccessActivity extends Activity {
  
      TextView successMessage;
      String failureMessage;
      DatabaseHelper myDb;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_success);
  
          myDb= new DatabaseHelper(this);
  
          myDb.insertData(myDb, "This is a Random Message ");
  </code></pre>
  
  <p><strong>Error</strong></p>
  
  <pre><code>08-11 13:16:46.883: I/SqliteDatabaseCpp(22338): sqlite returned: error code = 1, msg = no such table: transactionsHistory, db=/data/data/com.example.ep/databases/ep
  08-11 13:16:46.903: E/SQLiteDatabase(22338): Error inserting MESSAGE=This is a Random Message 
  08-11 13:16:46.903: E/SQLiteDatabase(22338): android.database.sqlite.SQLiteException: no such table: transactionsHistory: , while compiling: INSERT INTO transactionsHistory(MESSAGE) VALUES (?)
  08-11 13:16:46.903: E/SQLiteDatabase(22338):    at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
  08-11 13:16:46.903: E/SQLiteDatabase(22338):    at android.database.sqlite.SQLiteCompiledSql.&lt;init&gt;(SQLiteCompiledSql.java:68)
  </code></pre>