title: Creating table dynamically (On Button Click) In Android
body: <p>I am writing an application and it needs tables to be created dynamically.
  I've written the following code :</p>
  
  <pre><code>public void CreateDynamicTables(String Table_Name, String Contact_ID, String Display_Name){
          dbs.execSQL("DROP TABLE IF EXISTS " + Table_Name);
          String query = "CREATE TABLE " + Table_Name + "(" + CID + " TEXT PRIMARY KEY, " + DName + " TEXT);";
          dbs.execSQL(query);
          SQLiteDatabase db = this.getWritableDatabase();
          ContentValues cv = new ContentValues();
          cv.put(CID, Contact_ID);
          cv.put(DName, Display_Name);
          db.insert(Table_Name, null, cv);
          db.close();
      }
  </code></pre>
  
  <p>But it crashes the application. Cannot find whats wrong with it.</p>
  
  <p>Logcat:</p>
  
  <p><img src="https://i.stack.imgur.com/NLOI9.jpg" alt="Logcat"></p>