Home » Android » android – Using an existing VARCHAR column with Room

android – Using an existing VARCHAR column with Room

Posted by: admin May 14, 2020 Leave a comment

Questions:

I’m trying to use my existing db with the Android Room.
However, one of my tables have a VARCHAR column.

It seems Room only supports TEXT and not VARCHAR. And sqlite doesn’t let to modify column type.

So, is there any way to use the existng table with VARCHAR fields in the Room? Or should I copy the whole table to a new one replacing VARCHAR to TEXT?

How to&Answers:

Yes, you will definitely need to copy the whole table to a new one and replace VARCHAR by TEXT. And the only way to do it is “outside” room. With the usual SQLite.

Answer:

You should not need to write migration for VARCHAR columns. Even though Room uses TEXT, it’s able to parse VARCHAR just fine.