title: Multiple Tables In SQlite android
body: <p>I wanna make a database in sqlite android ,and I wanna create 2 table in database ,and after that I wanna create tables dynamically. but my class DBAdapter just create one table and for other tables throws error "no such table" so what should I do for this? plz help me</p>
  
  <pre><code>    package com.example.asa;
  
  
  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;
  import android.util.Log;
  
  public class DBAdapter {
      public static final String KEY_ROWID_con = "_id";
      public static final String KEY_NAME_con = "name";
      public static final String KEY_NUMBER_con = "number";
      private static final String TAG = "DBAdapter";
      private static final String DATABASE_TABLE_con = "contacts";
  
      private static final String DATABASE_NAME = "MyDB";
      private static final int DATABASE_VERSION = 2;
  
      private static final String DATABASE_CREATE_con =
          "create table contacts (_id integer primary key autoincrement, "
          + "name text not null, number text not null);";
  
      private final Context context;    
  
      private DatabaseHelper DBHelper;
      private SQLiteDatabase db;
  
      public DBAdapter(Context ctx) 
      {
          this.context = ctx;
          DBHelper = new DatabaseHelper(context);
      }
  
      private static class DatabaseHelper extends SQLiteOpenHelper 
      {
          DatabaseHelper(Context context) 
          {
              super(context, DATABASE_NAME, null, DATABASE_VERSION);
          }
  
          @Override
          public void onCreate(SQLiteDatabase db) 
          {
              try {
                  db.execSQL(DATABASE_CREATE_con);    
              } catch (SQLException e) {
                  e.printStackTrace();
              }
          }
  
          @Override
          public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) 
          {
              Log.w(TAG, "Upgrading database from version " + oldVersion + " to "
                      + newVersion + ", which will destroy all old data");
              db.execSQL("DROP TABLE IF EXISTS chats");
              onCreate(db);
          }
      }    
  
      //---opens the database---
      public DBAdapter open() throws SQLException 
      {
          db = DBHelper.getWritableDatabase();
          return this;
      }
  
      //---closes the database---    
      public void close() 
      {
          DBHelper.close();
      }
  
      //---insert a contact into the database---
      public long insertContact(String name, String number) 
      {
          ContentValues initialValues = new ContentValues();
          initialValues.put(KEY_NAME_con, name);
          initialValues.put(KEY_NUMBER_con, number);
          return db.insert(DATABASE_TABLE_con, null, initialValues);
      }
  
      //---deletes a particular contact---
      public boolean deleteContact(long rowId) 
      {
          return db.delete(DATABASE_TABLE_con, KEY_ROWID_con + "=" + rowId, null) &gt; 0;
      }
  
      //---retrieves all the contacts---
      public Cursor getAllContacts() 
      {
          return db.query(DATABASE_TABLE_con, new String[] {KEY_ROWID_con, KEY_NAME_con,
                  KEY_NUMBER_con}, null, null, null, null, null);
      }
  
      //---retrieves a particular contact---
      public Cursor getContact(long rowId) throws SQLException 
      {
          Cursor mCursor =
                  db.query(true, DATABASE_TABLE_con, new String[] {KEY_ROWID_con,
                  KEY_NAME_con, KEY_NUMBER_con}, KEY_ROWID_con + "=" + rowId, null,
                  null, null, null, null);
          if (mCursor != null) {
              mCursor.moveToFirst();
          }
          return mCursor;
      }
  
      //---updates a contact---
      public boolean updateContact(long rowId, String name, String number) 
      {
          ContentValues args = new ContentValues();
          args.put(KEY_NAME_con, name);
          args.put(KEY_NUMBER_con, number);
          return db.update(DATABASE_TABLE_con, args, KEY_ROWID_con + "=" + rowId, null) &gt; 0;
      }
  
      //---Search Contact by String ---//
      public String Search(String str)
      {
          String [] columns = new String[]{ KEY_ROWID_con, KEY_NAME_con, KEY_NUMBER_con};
          return db.query(DATABASE_TABLE_con, columns, KEY_NAME_con + "=?", new String[] { str }, null, null, null).getString(0);
      }
  
      //---insert a contact into the database---
  
      }
  </code></pre>