???????????
????Andoird??SQLiteOpenHelper?????????onUpgrade????????????????????????????????÷???????????????????????????????????????
????1. ????????????“?????????”???????
??????????????????????1.0?汾???ó???????????????1.1?汾???????????????????????????????Ρ???????1.0?汾?????????????1.1?汾??????????
????2. ???????????????????
?????????1.0?汾??????1.1?汾?????????????????????1.1?汾?????????е????????????μ?????汾???????????????????????а? ??1.0????????????????1.1??????????????????仰??????1.0???????????????????????????Σ???????????????????
????3. ????????????????????????
????SQLiteOpenHelper???????????????????int version?????????????????汾????????????1.0?汾?У????????SQLiteOpenHelper?????????????ò????1??????????汾??1??д?????????????С?
????????1.1?汾????????????????????仯?????????1.1?汾??????????????????1????????????SQLiteOpenHelper??????????μ??????????2??
???????????1.1?3?????1.0?汾?????????????????????????洢???????汾??1?????????3????????????汾???2?????????????????????
????4. ???????????????????????????
?????????????SQLiteOpenHelper????????????????汾?????????????????onUpgrade???????????????????????????????????????????????????????а???汾???????????????????Σ??????????????????????ɡ?
?????°汾?????汾????????onUpgrade??????????????????????????????????????????汾??????????汾??
??????????????????????洢?μ?汾???????????汾???
?????ο???StackOverFlow??“?????汾????????е?洢λ??”?????
?????????????Android???????????????SQLite?????????????????????????е??????????????????????μ??????????????? SQLite?????????????????? SQLite????ALTER TABLE???????????????????????μ???ε????б??У?????????????????Ρ?
????????????????β?????Σ????磬? Subscription?????????Σ?
????1 ALTER TABLE Subscription ADD COLUMN Activation BLOB;
????2 ALTER TABLE Subscription ADD COLUMN Key BLOB;
??????????????????????????????????????????????????????????????????????????????????????????????????????
????1. ??????????????
????ALTER TABLE Subscription RENAME TO __temp__Subscription;
????2. ?????±?
????CREATE TABLE Subscription (OrderId VARCHAR(32) PRIMARY KEY ??UserName VARCHAR(32) NOTNULL ??ProductId VARCHAR(16) NOT NULL);
????3. ????????
????INSERT INTO Subscription SELECT OrderId?? “”?? ProductId FROM __temp__Subscription;
????????
????INSERT INTO Subscription() SELECT OrderId?? “”?? ProductId FROM __temp__Subscription;
????* ??? ?????”” ?????????????????????????
????4. ????????
????DROP TABLE __temp__Subscription;
?????????????????裬?????????????????????????????????????л???????????????????????????
??????????????????????ε????????????????????????????????