-1

Approach uses ALTER TABLE to add columns when backup and RESTORE a database file in android. How to set new columns position in table. The columns is showing as a last columns in table but i need this column in middle.

Cœur
  • 37,241
  • 25
  • 195
  • 267

2 Answers2

1

You can try different approaches to maintain the positioning of columns.

One way can be to 1) rename your table 2) create new table with correct column ordering 3) then insert all records from renamed table. This is mentioned on following link: https://stackoverflow.com/a/4253879/867475

Another approach can be to add the column at the end and use Views to fetch columns in correct ordering. Example.

Community
  • 1
  • 1
rizzz86
  • 3,862
  • 8
  • 35
  • 52
0

As per documentation

The ADD COLUMN syntax is used to add a new column to an existing table. The new column is always appended to the end of the list of existing columns.

But, there is a work around way. Read this answer on SO.

Refer to: SQLite: ALTER TABLE: ADD COLUMN

Community
  • 1
  • 1
Vishal
  • 211
  • 2
  • 8