NativeScript-Android-preferences
一个NativeScript插件,允许在Android上使用应用程序的偏好设置。
npm i --save nativescript-android-preferences

NativeScript-Android-preferences

一个NativeScript插件,允许在Android上使用应用程序的偏好设置。

许可证

此插件由Elsa Rodriguez Plaza许可,采用MIT许可证

安装

tns plugin add nativescript-android-preferences

用法

有关如何使用此插件更详细的说明,请查看演示应用程序

<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="onNavigatingTo">
<StackLayout>
<Label text="Android App Save Preferences" class="title"/>
<Button text="Save String" tap="{{ onTapString }}" />
</StackLayout>
</Page>
var pref = require("nativescript-android-preferences");
onTapString = function () {
var options = {
datavalue: "StringPreference",
datatype: pref.DataTypes.STRING,
prefname: "String_Preference"
}
pref.SavePreference(options);
options.datavalue = "DefStringPreference";
alert("String Preference saved:"+pref.GetPreference(options));
}