User Tools

Site Tools


Privacy Policy


Version 2.50 is out since Jan 1st 2022

Frequently Asked Questions


Note for contributors

If you wish to create a new page in the DroidScript wiki, please click on the most appropriate namespace above and follow the notes for contributors there.

Because of spam, it has been necessary to add a CAPTCHA to the registration form and the save option for editing pages. You will not need to prove you are human if you are logged in, so please register.

Please feel free to improve any existing page, as well as adding new pages to increase the sum of public knowledge about DroidScript.

Formatting Syntax


Backup your apps

Following a reminder from Dave on the discussion group that we should be backing up our apps regularly, I thought I would post a simple way of sending yourself an email archive of your DroidScript folder.

The following code is intended as a guide to one way you can keep a snapshot of your code at any given time.

If you wish, you can save the mail as a draft, rather than sending it.

Or instead of choosing a mail app to send the file, you may be able to choose an archiving app that is on your device, such as Google Drive.

var mygmail = app.GetUser();
var txt, yesNo, archname;
//Called when application is started.
function OnStart()
    //Create a layout with objects vertically centered.
    var lay = app.CreateLayout( "linear", "FillXY" );    
    //Create a text label and add it to layout.
    txt = app.CreateText( "..." );
    lay.AddChild( txt );
    //Add layout to app.    
    app.AddLayout( lay );
    var fname = CreateArchive();
    yesNo = app.CreateYesNoDialog( "Send by mail?" ); 
    yesNo.fname = fname;
    yesNo.SetOnTouch( yesNoMail_OnTouch );
//Create a backup archive.
function CreateArchive( )
    var archfolder = "/sdcard/sjgapps/archive/"; 
    //Create project zip file.
    var zip = app.CreateZipUtil();
    var fldr = "/sdcard/DroidScript";
    archname = (new Date).toISOString().slice(0,19 );
    archname = "ds"+archname.replace(/[-:]/g,"");
    archname =  archname.replace(/T/,"_");
    archname += ".zip";
    var file = archfolder+archname;
    archname = app.GetModel()+"/"+archname;
    zip.Create( file );
    app.ShowProgress( "Archiving..." );
    AddFolder( zip, "DroidScript", fldr );
    return file;
//Recursively add folder contents to zip.
function AddFolder( zip, name, fldr )
    var list = app.ListFolder( fldr,"",0,"alphasort" );
    for( var i=0; i<list.length; i++ )
        var title = list[i];
        if( !app.IsFolder( fldr+"/"+title ) )
            zip.AddFile( name+"/"+title, fldr+"/"+title );
            AddFolder( zip, name+"/"+title, fldr+"/"+title );
//Handle 'send by mail?' dialog. 
function yesNoMail_OnTouch( result ) 
    if( result=="Yes" ) 
        var fname = yesNo.fname;
        app.SendMail( mygmail, archname, "DroidScript backup attached", fname );


Version required

This code makes the assumption that you are using at least version 1.15 of DroidScript, as the path for your apps is hard coded but older versions used a different path

Filling your sdcard

There is no code included to delete the zip files.

Over time, /sdcard/sjgapps/archive will build up all the archives you create.

You should probably delete those files manually from time to time, probably after emailing them or placing them in your cloud storage.

sample_code/backup_apps.txt · Last modified: 2015/11/15 00:00 (external edit)