我试图在一个数据库中创建两个表,在android studio上使用sqlite。 创建第一个表后,创建第二个表时出错(第三列不存在)
package com.mbsps.doctorhelper;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import java.text.SimpleDateFormat;
public class DBHandler extends SQLiteOpenHelper {
public String dateReq;
// Database Version
private static final int DATABASE_VERSION = 1;
// Database Name
private static final String DATABASE_NAME ="DBDoctorshelper";
// Contacts table name
private static final String TABLE_Emails ="emails";
// Table Columns names
private static final String KEY_NAME ="FirstName";
private static final String KEY_LASTNAME ="LastName";
private static final String KEY_AGE= "Age";
private static final String KEY_DATENTIME= "DatenTime";
private static final String KEY_LOCATION= "Location";
private static final String KEY_ALLERGIES= "Allergies";
private static final String KEY_MEDICINE= "Medicine";
private static final String KEY_REFERREBY= "ReferedBy";
public static final String CREATE_QUERY =
"CREATE TABLE "+ ContractUser.UserInfo.TABLE_NAME + " ("+ ContractUser.UserInfo.USER_EMAIL+" TEXT,"+ ContractUser.UserInfo.USER_PASSWORD+" TEXT);";
public static final String CREATE_QUERY2=
"CREATE TABLE " + TABLE_Emails+"(" + KEY_NAME + " TEXT," + KEY_LASTNAME + " TEXT," + KEY_AGE + " TEXT," + KEY_DATENTIME + " DATE," + KEY_LOCATION + " TEXT," + KEY_ALLERGIES + " TEXT," + KEY_MEDICINE + " TEXT);";
public DBHandler(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
Log.e("DATABASE OPERATIONS", "Database created/ opened.");
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(CREATE_QUERY);
Log.e("DATABASE OPERATIONS", "Table Doc_info created");
db.execSQL(CREATE_QUERY2);
Log.e("DATABASE OPERATIONS", "Table emails created");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
db.execSQL("DROP TABLE IF EXISTS"+ ContractUser.UserInfo.TABLE_NAME);
db.execSQL("DROP TABLE IF EXISTS"+ TABLE_Emails);
}
我需要帮助