How to update table with activeandroid after adding a new column How to update table with activeandroid after adding a new column database database

How to update table with activeandroid after adding a new column


From the sounds of it, you're missing the upgrade script to migrate your user table to the new schema. The upgrade scripts basically contains the instructions on how to get from the old state of the database to the new one. In your specific case, you'll want to tell SQLite that it should add a new column, profile_image, to the existing user table.

To upgrade your database from schema 1 to 2, bump up the AA_DB_VERSION value to 2 and give the upgrade script the name 2.sql. Save the file under assets/migrations and give it the following content:

ALTER TABLE user ADD profile_image TEXT;

The scripts may contains any set of SQL statements that can be executed by the SQLiteDatabase through execSQL(...).

More details on schema migrations with Active Android can be found in the wiki on the GitHub project page.


The "TEXT" label is changed to "VARCHAR" for database migration using ActiveAndroid

All other Reserved words were highlighted except for "TEXT". I used "VARCHAR" and it worked.