I have a table in my android app that is very simple. Has an id and a few longs/ints for values. I haven’t updated my app in a while but I am working on a huge, totally revamped version. I thought about making the app completely independent of the original one but that would potentially disappoint current users. Instead, I’ll make it as a big upgrade off the last iteration. I’m wondering whether I should copy all of the data to a new table and trash the old one or just modify the schema of the existing table and avoid having to delete?
Another question I have is….if I were to go about doing either of these tasks, how would I do so WITH fixed, predetermined values for the new entries in all of the rows corresponding with the original table? I guess it may be hard to understand what I’m truly asking. Let’s say I want a value of “5” added to every row a new column in a table already made. Can I easily go about doing so? If so, how?
EDIT:
I’m gonna be a lot more specific and provide you with what I really want to do. I have 1 table. Let’s call it Z. Z consists of an autoincrement int primary key, int date, numeric price, numeric length, and numeric amount. I will add another table, X, which will have an autoincrement int primary key, and a string value for the name. In table Z, I want to add the attributes: int type, and int x_id (this will link to the string in the X table). How would I go about ALTERING my original table Z using onUpgrade() then populate the new attributes (type and x_id) with 2 variables (in Java)?
If you change your table’s layout or create a new one depends on the actual changes and your personal preferences, there is no general answer to that question.
You can do all necessary upgrades/migration tasks in the onUpgrade Method of you SQLiteOpenHelper subclass(es)