0

I have been trying to add a column to my sqlite database in android studio using the ALTER query but it is not working. Please guide me on how i can do it

 if (newVersion> oldVersion) {
        db.execSQL("ALTER TABLE Animals_calendar ADD COLUMN Deworming TEXT ");
    }
Julius Elvis
  • 31
  • 1
  • 1
  • 4
  • Possible duplicate of [How to add new Column to Android SQLite Database?](https://stackoverflow.com/questions/8291673/how-to-add-new-column-to-android-sqlite-database) – Tim Biegeleisen Mar 28 '19 at 13:25
  • Your code looks fine to me. Have you tried running it? – Tim Biegeleisen Mar 28 '19 at 13:25
  • What "is not working" means?, are you getting an error? Include it on the question, If not, probably your program is nor reaching that code, in this case we need to see how an where are you calling it – Daniel Brughera Mar 28 '19 at 13:43
  • i have tried running it but it doesn't add the new column to my table when i open the database after running. – Julius Elvis Mar 28 '19 at 13:56
  • Is the above code in the **onUpgrade** method of the database helper (class that extends SQLIteOpenHelper) and if so have you increased the version number (4th parameter passed to the super call in the constructor). Perhaps edit your question to include the entire database helper. – MikeT Mar 28 '19 at 20:39

0 Answers0