** Hello, I have an application in the App Store and I want to update it. If I update it will the data in the database be deleted? For example, people who have registered will lose their account?
Someone enlighten me please **
** Hello, I have an application in the App Store and I want to update it. If I update it will the data in the database be deleted? For example, people who have registered will lose their account?
Someone enlighten me please **
If you update the app ( versionCode
) the data is not lost. If you modify / update the SQLite database if the data can be lost. I think the most common is to add a column to a BD, therefore you have to update the code: in DATABASE_VERSION
change to a larger number, in onCreate
you add the new column, and if you do not want to lose data already saved in the database, use the ALTER TABLE
in the onUpgrade
method. Example:
@Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
if (newVersion > oldVersion) {
db.execSQL("ALTER TABLE tutabla ADD COLUMN tu_nueva_columna INTEGER");
//db.execSQL("ALTER TABLE tutabla ADD COLUMN tu_nueva_columna"); // sin mencionar el tipo
}
}