title: Create sqlite tables dynamically
body: <p>My code is creating sqlite one sqlite table that save the input data on clicking at the add button, what I want to do is every time I click to the button <code>NewTab</code> a new table will be created, I searched everywhere and I tried sharedpreferences also to make different name of tables nothing helped me, can any one help plz and thank you.</p>
  
  <pre><code>public class MyDBHandler extends SQLiteOpenHelper{
  public static final String DATABASE_NAME = "Shopping.db";
  public static final String TABLE_NAME = "Main_table";
  
  public static final String COL_2 = "NAME";
  public static final String COL_3 = "PRICE";
  
  public MyDBHandler(Context context) {
      super(context, DATABASE_NAME, null, 1);
  }
  
  @Override
  public void onCreate(SQLiteDatabase db) {
      db.execSQL("create table " + TABLE_NAME +" (ID INTEGER PRIMARY KEY AUTOINCREMENT,NAME TEXT,PRICE TEXT)");
  }
  
  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
      db.execSQL("DROP TABLE IF EXISTS "+TABLE_NAME);
      onCreate(db);
  }
  
  public boolean insertData(String name,String price) {
      SQLiteDatabase db = this.getWritableDatabase();
      ContentValues contentValues = new ContentValues();
      contentValues.put(COL_2,name);
      contentValues.put(COL_3,price);
      long result = db.insert(TABLE_NAME,null ,contentValues);
      if(result == -1)
          return false;
      else
          return true;
  }
  
  public Cursor getAllData() {
      SQLiteDatabase db = this.getWritableDatabase();
      Cursor res = db.rawQuery("select * from "+TABLE_NAME,null);
      return res;
  }
  </code></pre>
  
  <p>}</p>
  
  <p><strong>MainActivty</strong></p>
  
  <pre><code>    btnAddData.setOnClickListener(
                  new View.OnClickListener() {
                      @Override
                      public void onClick(View v) {
                          MyDBHandler myDb = new MyDBHandler(MainActivity.this);
                          boolean isInserted = myDb.insertData(editName.getText().toString(), null);
                          if (isInserted == true) {
                              Toast.makeText(MainActivity.this, "Data Inserted", Toast.LENGTH_LONG).show();
                              Cursor res = myDb.getAllData();
  
                              while (res.moveToNext()) {
                                  final TextView textView = new TextView(MainActivity.this);
  
                                  String valor1 = "&lt;p style='font-family:verdana'&gt;" + a + "&lt;/p&gt; ";
                                  textView.setText(Html.fromHtml(valor1));
                                  lin.addView(textView);
  
  
  
                              }
  
  
                          } else {
                              Toast.makeText(MainActivity.this, "Data not Inserted", Toast.LENGTH_LONG).show();
                          }
                      }
                  }
          );
  </code></pre>