I'm trying to add new tables to my database.
I changed the db version, but it's not working - still have the same tables
Heres is SQLITEOPENGELPER class
public class DB extends SQLiteOpenHelper {
public final static String DBNAME="MEDCINEDB.db";
public final static String Table_name="MEDCINETable";
public final static String Table_name2="PPLTABLE";
public final static String col1="MEDCINEID";
public final static String col2="MEDCINENAME";
public final static String col3="MEDCINEPURPOSE";
public final static String col4="NOTAPLET";
public final static String col1T2="ID";
public final static String col2T2="NAMEPPL";
public final static String col3T2="AGEPPL";
public final static int DBVersion =2;
public DB(Context context,String DBNAME, int DBVersion) {
super(context, DBNAME, null, DBVersion);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE " + Table_name + "(MEDCINEID INTEGER PRIMARY KEY AUTOINCREMENT,MEDCINENAME TEXT,MEDCINEPURPOSE TEXT,NOTAPLET INTEGER)");
db.execSQL("CREATE TABLE " + Table_name2 + "(ID INTEGER PRIMARY KEY AUTOINCREMENT,NAMEPPL TEXT,AGEPPL INTEGER)");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP IF EXISTS"+Table_name);
db.execSQL("DROP IF EXISTS"+Table_name2);
onCreate(db);
}}
Aucun commentaire:
Enregistrer un commentaire