title: How to add another table and insert values in existing SQLite Database in Android?
body: <p>I want to add another table in my existing Sqlite database for my android application. I have created one table "dailytips" and want to add another table "healthytips". i have tried different ways but didn't succeed and also done google search but every code is different from mine. Please some one help me in this.</p>
  
  <p>Here is my code:</p>
  
  <pre><code> package com.example.health;
  
   import android.content.ContentValues;
   import android.content.Context;
   import android.database.Cursor;
   import android.database.sqlite.SQLiteDatabase;
   import android.database.sqlite.SQLiteOpenHelper;
   import android.database.sqlite.SQLiteDatabase.CursorFactory;
  
   public class SQLiteAdapter {
  
   public static final int DATABASE_VERSION = 2;
   public static final String DATABASE_NAME = "healthDB";
  
   public static final String TABLE_DAILY = "dailytips";
   public static final String COLUMN_ID = "_id";
   public static final String COLUMN_TIPS = "tips";
  
   public static final String TABLE_HEALTH="healthytips";
   public static final String COLUMN_H_ID = "_id";
   public static final String COLUMN_H_TIPS = "tips";
  
   //create table TABLE_DAILY (ID integer primary key, tips text not null);
   private static final String CREATE_TABLE_DAILYS =
   "create table " + TABLE_DAILY + " ("
   + COLUMN_ID + " integer primary key autoincrement, "
   + COLUMN_TIPS + " text not null);";
  
   //create table TABLE_HEALTHY (ID integer primary key, tips text not null);
   private static final String CREATE_TABLE_HEALTH=
   "create table " + TABLE_HEALTH + " ("
   + COLUMN_H_ID + " integer primary key autoincrement, "
   + COLUMN_H_TIPS + " text not null);";
  
   private SQLiteHelper sqLiteHelper;
   private SQLiteDatabase sqLiteDatabase;
  
   private Context context;
  
   public SQLiteAdapter(Context c){
   context = c;
    }
  
   public SQLiteAdapter openToRead() throws android.database.SQLException {
   sqLiteHelper = new SQLiteHelper(context, DATABASE_NAME, null, DATABASE_VERSION);
  sqLiteDatabase = sqLiteHelper.getReadableDatabase();
  return this;
   }
  
   public SQLiteAdapter openToWrite() throws android.database.SQLException {
   sqLiteHelper = new SQLiteHelper(context, DATABASE_NAME, null, DATABASE_VERSION);
   sqLiteDatabase = sqLiteHelper.getWritableDatabase();
   return this;
   }
  
   public void close(){
   sqLiteHelper.close();
   }
  
   public long insert(String tips){
  
   ContentValues contentValues = new ContentValues();
   contentValues.put(COLUMN_TIPS, tips);
   return sqLiteDatabase.insert(TABLE_DAILY, null, contentValues);
   }
  
   public int deleteAll(){
   return sqLiteDatabase.delete(TABLE_DAILY, null, null);
   }
  
   public Cursor queueAll(){
   String[] columns = new String[]{COLUMN_ID, COLUMN_TIPS};
   Cursor cursor = sqLiteDatabase.query(TABLE_DAILY, columns,
     null, null, null, null, null);
   return cursor;
   }
  
   public class SQLiteHelper extends SQLiteOpenHelper {
  
   public SQLiteHelper(Context context, String name,
   CursorFactory factory, int version) {
   super(context, name, factory, version);
    }
  
   @Override
   public void onCreate(SQLiteDatabase db) {
   // TODO Auto-generated method stub
   db.execSQL(CREATE_TABLE_DAILYS);
   db.execSQL(CREATE_TABLE_HEALTH);
    }
  
   @Override
   public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    // TODO Auto-generated method stub
  
   }
   }}
  </code></pre>