Skip to content
Advertisement

How to add column on existing table in android SQLite?

how to add column in the existing table LOGIN. here’s my sample code.

this is my DataBaseAdapter class:

JavaScript

this is my LoginDataBaseAdapter

JavaScript

how can I add the columns FIRSTNAME(from TextView), LASTNAME(from TextView), DEPARTMENT(from Spinner).

Advertisement

Answer

You’ll have to update your SQLite database version first of all, then that will run your onUpgrade() method, which will drop all of your data. Then the table will be remade with the new schema that you have defined in your DATABASE_CREATE string.

So the main issue that this comes with is that you’ll have to find a way to recover the data that is already existing in the table as the table will be dropped. You do get to run onUpgrade before this happens though so use this method as a point to save any data you need to from the database.

JavaScript

and update your database creation string.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement