Saves variables until the app closes. All saved data will be lost afterwards.
Example - Basic
function OnStart()
{
app.SetData( "myvar", "Hello World!" );
var data = app.GetData("myvar");
app.Alert( data, "Saved Data:" );
}
from native import app
def OnStart():
app.SetData( "myvar", "Hello World!" )
data = app.GetData("myvar")
app.Alert( data, "Saved Data:" )
Example - Random Value
function OnStart()
{
lay = app.CreateLayout( "linear", "VCenter,FillXY" );
btn = app.AddButton( lay, "Press Me", 0.3, 0.1 );
btn.SetOnTouch( btn_OnTouch );
app.AddLayout( lay );
}
function btn_OnTouch()
{
var data = 100 * Math.random() | 0;
app.SetData( "number", data );
app.ShowPopup( "Data: " + app.GetData( "number" ));
}
from native import app
def OnStart():
lay = app.CreateLayout( "linear", "VCenter,FillXY" )
btn = app.AddButton( lay, "Press Me", 0.3, 0.1 )
btn.SetOnTouch( btn_OnTouch )
app.AddLayout( lay )
def btn_OnTouch():
data = str(int(100 * (random.random())))
app.SetData( "number", data )
app.ShowPopup( "Data: " + app.GetData( "number" ))