Application-settings - not persistent after app upgrade?

ios
android

#1

Hi,
I use application-settings to store some small user related data. I thought that after user performs an app update to a newer version, the data would still be kept, however, I think it is not the case from my checks (both on an emulator and on an android device).
I couldn’t find any official documentation to clarify this, could you help me?
Could it have something to with the fact the the NS version of the newer app version was updated compared to the old one?
The question is relevant to both android and ios.
Thanks!


#2

application-settings must be persistent over app updates in both iOS and Android. You may loose data only when app is uninstalled or user clear the app data from settings.


#3

Thanks for the repy. In my case, it did not happen, what I tried is:

  1. Running old app version on the emulator and afterwards the running the new one (without uninstalling)
  2. Installing old version on a real device from google play and then installing the new one from an APK.
    Any idea what the reason for this can be?

#4

Rarely application settings may be lost for unknown reasons, I have also experienced it and I have seen people facing same issue not only with NativeScript but even with native apps too. But it should not be like every time.

Here is what I did,

  1. I created a app from blank typescript template (tns create my-app-name --template tns-template-hello-world-ts - CLI v4.1.2)
  2. Updated the view model as below
  3. Built release version of APK and installed same on Android 8.0
  4. Upon first launch it shown “Nothing yet” as expected
  5. Tap the button which saves current time in application settings
  6. Now updated versionName to 1.1 and versionCode to 2 in the manifest file
  7. Built release version of APK and updated app on Android 8.0
  8. Launched the app again and it shown me the timestamp saved in the earlier session

main-view-model.ts

import * as appSettings from 'application-settings';
import { Observable } from 'data/observable';

export class HelloWorldModel extends Observable {

    private _message: string;

    constructor() {
        super();
        this._message = appSettings.getString('message', 'Nothing yet');
    }

    get message(): string {
        return this._message;
    }

    set message(value: string) {
        appSettings.setString('message', value);
        this.notifyPropertyChange('message', value)
    }

    public onTap() {
        this.message = new Date().getTime().toString();
    }
}

@tigrenok00 Can you please run the same tests on your end and let us know.