Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
バージョンのアップグレードで、Android には存在しない sqlite データベース テーブルに新しい列を追加したいと考えています。列がすでに存在する場合、テーブルを変更するべきではありません。onUpgrade() メソッドでは、データを失いたくないので、テーブルを削除していません。
@Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // If you need to add a column if (newVersion > oldVersion) { if(!ColunmExists) { db.execSQL("ALTER TABLE foo ADD COLUMN new_column INTEGER DEFAULT 0"); } } }