User Tools

Site Tools


Sidebar

Privacy Policy

News

Version 2.50 is out since Jan 1st 2022


Frequently Asked Questions


Namespaces

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

sample_code:list_folders_and_subfolders

List all Folders and Subfolders

(Sample Code taken from the DroidScript Google-Group)

Folders_and_Subfolders.js
//Called when application is started.
function OnStart()
{
  //Create a layout with objects vertically centered.
  lay = app.CreateLayout("linear", "VCenter,FillXY");
 
  //Create a list and add to layout.
  lst = app.CreateList("Please Wait");
  lay.AddChild(lst);
  //Add layout to app.
  app.AddLayout(lay);
 
  app.ShowProgress("Loading...");
  lst.SetList(GetDirs("/sdcard/DroidScript", []).sort());
  app.HideProgress();
}
 
//Check a directory for subdirectories.
function GetDirs(path, kidsfound)
{
  if (path != null && app.IsFolder(path))
  {
    kidsfound.push(path);
    var children = app.ListFolder(path);
    for (var i = 0; i < children.length; i++)
    {
      var fil = path + "/" + children[i];
      if (app.IsFolder(fil))
      {
        kidsfound = GetDirs(fil, kidsfound);
      }
    }
  }
  return kidsfound;
}
sample_code/list_folders_and_subfolders.txt · Last modified: 2014/12/18 00:17 (external edit)