11// >> app-settings-code
22import { Component } from "@angular/core" ;
3- import {
4- getBoolean ,
5- setBoolean ,
6- getNumber ,
7- setNumber ,
8- getString ,
9- setString ,
10- hasKey ,
11- remove ,
12- clear
13- } from "tns-core-modules/application-settings" ;
3+ import { ApplicationSettings } from "@nativescript/core" ;
144
155@Component ( {
166 moduleId : module . id ,
@@ -19,27 +9,27 @@ import {
199export class UsageComponent {
2010
2111 constructor ( ) {
22- setBoolean ( "isTurnedOn" , true ) ;
23- setString ( "username" , "Wolfgang" ) ;
24- setNumber ( "locationX" , 54.321 ) ;
12+ ApplicationSettings . setBoolean ( "isTurnedOn" , true ) ;
13+ ApplicationSettings . setString ( "username" , "Wolfgang" ) ;
14+ ApplicationSettings . setNumber ( "locationX" , 54.321 ) ;
2515
26- const isTurnedOn : boolean = getBoolean ( "isTurnedOn" ) ;
27- const username : string = getString ( "username" ) ;
28- const locationX : number = getNumber ( "locationX" ) ;
16+ const isTurnedOn : boolean = ApplicationSettings . getBoolean ( "isTurnedOn" ) ;
17+ const username : string = ApplicationSettings . getString ( "username" ) ;
18+ const locationX : number = ApplicationSettings . getNumber ( "locationX" ) ;
2919
3020 // Will return "No string value" if there is no value for "noSuchKey"
31- const someKey : string = getString ( "noSuchKey" , "No string value" ) ;
21+ const someKey : string = ApplicationSettings . getString ( "noSuchKey" , "No string value" ) ;
3222
3323 // Will return false if there is no key with name "noSuchKey"
34- let isKeExisting : boolean = hasKey ( "noSuchKey" ) ;
24+ let isKeExisting : boolean = ApplicationSettings . hasKey ( "noSuchKey" ) ;
3525 }
3626
3727 onClearß ( ) {
3828 // Removing a single entry via its key name
39- remove ( "isTurnedOn" ) ;
29+ ApplicationSettings . remove ( "isTurnedOn" ) ;
4030
4131 // Clearing the whole application-settings for this app
42- clear ( ) ;
32+ ApplicationSettings . clear ( ) ;
4333 }
4434}
4535// << app-settings-code
0 commit comments