03-13-2019 08:13
03-13-2019 08:13
Trying to figure out how to delete and re-create the file where I save the settings for my clockface whenever the app is re-installed. Is there an event that fires on installation? Or is there some other way to perform a certain function only when the app is first installed?
Thanks.
03-14-2019 09:34
03-14-2019 09:34
There's not an API for this, but you can write a file to the file system containing a version number, or check for the existence of a particular version of the settings file. e.g.
try {
settings = fs.readFileSync("settings-v2.cbor", "cbor");
} catch(ex) {}
if (!settings) {
try {
settings = fs.readFileSync("settings.cbor", "cbor");
} catch (ex) {
settings = defaults;
}
}