ClearValue deletes a variable saved via app.Save*().
The file parameter is optional. If given, the specified file will be used, otherwise it will be located in the apps private Folder.
See Also: SaveText, SaveNumber, SaveBoolean
Example - Save, Load and Clear Data
var file = "demofile";
function OnStart()
{
lay = app.CreateLayout( "linear", "VCenter,FillXY" );
var text = app.LoadText( "value", "My Value", file );
edtValue = app.CreateTextEdit( text, .5 );
lay.AddChild( edtValue );
btnSave = app.CreateButton( "Save Value", 0.5, 0.1 );
btnSave.SetOnTouch( btnSave_OnTouch );
lay.AddChild( btnSave );
btnLoad = app.CreateButton( "Load Value", 0.5, 0.1 );
btnLoad.SetOnTouch( btnLoad_OnTouch );
lay.AddChild( btnLoad );
btnClear = app.CreateButton( "Clear Value", 0.5, 0.1 );
btnClear.SetOnTouch( btnClear_OnTouch );
lay.AddChild( btnClear );
app.AddLayout( lay );
}
function btnSave_OnTouch()
{
app.SaveText( "value", edtValue.GetText(), file );
app.ShowPopup( "Value Saved." );
}
function btnLoad_OnTouch()
{
var value = app.LoadText( "value", "no value stored", file );
app.ShowPopup( value );
}
function btnClear_OnTouch()
{
app.ClearData( file );
app.ShowPopup( "Data Cleared." );
}
from native import app
file = "demofile"
def OnStart():
global edtValue
lay = app.CreateLayout( "linear", "VCenter,FillXY" )
text = app.LoadText( "value", "My Value", file )
edtValue = app.CreateTextEdit( text, .5 )
lay.AddChild( edtValue )
btnSave = app.CreateButton( "Save Value", 0.5, 0.1 )
btnSave.SetOnTouch( btnSave_OnTouch )
lay.AddChild( btnSave )
btnLoad = app.CreateButton( "Load Value", 0.5, 0.1 )
btnLoad.SetOnTouch( btnLoad_OnTouch )
lay.AddChild( btnLoad )
btnClear = app.CreateButton( "Clear Value", 0.5, 0.1 )
btnClear.SetOnTouch( btnClear_OnTouch )
lay.AddChild( btnClear )
app.AddLayout( lay )
def btnSave_OnTouch():
app.SaveText( "value", edtValue.GetText(), file )
app.ShowPopup( "Value Saved." )
def btnLoad_OnTouch():
value = app.LoadText( "value", "no value stored", file )
app.ShowPopup( value )
def btnClear_OnTouch():
app.ClearData( file )
app.ShowPopup( "Data Cleared." )