Do not call getWritableDatabase()
. Use the one that was passed in:
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { String query = "ALTER TABLE names ADD COLUMN hidden integer default 0"; db.rawQuery(query, null); }
Why? When you call getWritableDatabase()
, OpenHelper detects that the database needs to be updated, so it triggers the recursion warning that you see. In other words, you are in onUpgrade()
. You call getWritableDatabase()
, which sees that an update is needed. If not for verification, you will return to onUpgrade()
, ad infinitum.
source share