Back

ClearData

JS Py
Hello World

ClearData deletes variables saved via app.Save*().

app.ClearData( file? )

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: SetData,

See Also: GetData

Example - Save, Load and Clear Data

var file = "demofile";

function OnStart()
{
    lay = app.CreateLayout( "linear", "VCenter,FillXY" );

    var text = getValues();
    txtValues = app.CreateText( text, .5, -1, "multiline,left" );
    lay.AddChild( txtValues );

    btnClear = app.CreateButton( "Clear Data", 0.5, 0.1 );
    btnClear.SetOnTouch( btnClear_OnTouch );
    lay.AddChild( btnClear );

    app.AddLayout( lay );
}

function btnClear_OnTouch()
{
    app.ClearData( file );
    txtValues.SetText( getValues() );
    app.ShowPopup( "Data Cleared." );
}

function getValues()
{
    return (
        "saved Text: " + app.LoadText( "value", "No Value stored.", file ) + "\n" +
        "click count: " + app.LoadNumber( "clicks", 0, file ) + "\n" +
        "first start: " + app.LoadBoolean( "first", true, file ) + "\n");
}
from native import app

file = "demofile"

def OnStart():
    global txtValues
    lay = app.CreateLayout( "linear", "VCenter,FillXY" )

    text = getValues()
    txtValues = app.CreateText( text, .5, -1, "multiline,left" )
    lay.AddChild( txtValues )

    btnClear = app.CreateButton( "Clear Data", 0.5, 0.1 )
    btnClear.SetOnTouch( btnClear_OnTouch )
    lay.AddChild( btnClear )

    app.AddLayout( lay )

def btnClear_OnTouch():
    app.ClearData( file )
    txtValues.SetText( getValues() )
    app.ShowPopup( "Data Cleared." )

def getValues():
    return (
        "saved Text: " + app.LoadText( "value", "No Value stored.", file ) + "\n" +
        "click count: " + app.LoadNumber( "clicks", 0, file ) + "\n" +
        "first start: " + app.LoadBoolean( "first", True, file ) + "\n")
    Copy     Copy All       Run      
String: path to file ( “/absolute/...” or “relative/...” )