I traced the code. Tray will upgrade version in constructor (it will call isVersionChangeChecked()).
In isVersionChangeChecked(), it will check version(changeVersion()) to do onCreate/onUpgrade/onDowngrade if mChangeVersionSucceeded == false.
Notice that the variable mChangeVersionSucceeded is always false until the last line in changeVersion() (after finishing onCreate/onUpgrade/onDowngrade)
And the new version value (getStorage().setVersion(newVersion)) is also set after finishing onCreate/onUpgrade/onDowngrade
Assume I want to toggle a boolean value in new version. I write the code like ...
It calls isVersionChangeChecked() again!
At that time, mChangeVersionSucceeded is still false and getStorage().getVersion() is also the old version.
So...it will passes all IF statements then calls onUpgrade again and again.
Please teach me how to fix this issue? 😃
Sorry, I'm not good at English. 😞
tray Version
0.12.0
How have you setup tray
Initialized in Application.onCreate
Device(s)
too many (samsung, huawei, google, etc.)
Android Version
from 4.4 to 7
Description
I traced the code. Tray will upgrade version in constructor (it will call
isVersionChangeChecked()
).In
isVersionChangeChecked()
, it will check version(changeVersion()
) to doonCreate/onUpgrade/onDowngrade
ifmChangeVersionSucceeded == false
.Notice that the variable
mChangeVersionSucceeded
is alwaysfalse
until the last line inchangeVersion()
(after finishingonCreate/onUpgrade/onDowngrade
) And the new version value (getStorage().setVersion(newVersion)
) is also set after finishingonCreate/onUpgrade/onDowngrade
Assume I want to toggle a boolean value in new version. I write the code like ...
However, at the beginning of put method is...
It calls
isVersionChangeChecked()
again! At that time, mChangeVersionSucceeded is still false and getStorage().getVersion() is also the old version. So...it will passes all IF statements then callsonUpgrade
again and again.Please teach me how to fix this issue? 😃 Sorry, I'm not good at English. 😞