I have a 1(one) Table at first in my database. Then, I realized that I will add another table in that database.
@Override
public void onCreate(SQLiteDatabase db) {
String sql = "CREATE TABLE if not exists profile (" +
"email text primary key not null, " +
"username text, " +
"profilePicture text, " +
"about text)";
db.execSQL(sql);
sql = "CREATE TABLE if not exists current_user (" +
"email text)";
db.execSQL(sql);
sql = "INSERT INTO current_user(email)" +
"VALUES ('')";
db.execSQL(sql);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
String sql = "DROP TABLE IF EXISTS profile";
db.execSQL(sql);
sql = "DROP TABLE IF EXISTS current_user";
db.execSQL(sql);
onCreate(db);
}
When I want to update the email of my current_user it sends me an exception
public void setCurrentEmail(String email){
ContentValues rsValues = new ContentValues();
rsValues.put("email", email);
database.update("current_user", rsValues, null, null);
}
no such table: current_user (code 1):
Others say that, you must change the name of the Database for it to work but are there any alternatives?