#Region Project Attributes #ApplicationLabel: sortbydatefiletest #VersionCode: 20140627#versionname: ' Supportedorientations possible values:unspecified, landscape or Portrait. #SupportedOrientations: unspecified# Caninstalltoexternalstorage:false#end region#region Activity Attributes #FullScreen: false#includetitle:true#end Regionsub process_globals ' These global variables would be declared once when the application starts. ' These variables can is accessed from all modules. Type Fileandtime (Name as String, time as Long) End SubSub Globals ' These global variables'll be redeclared each time the A Ctivity is created. ' These variables can only is accessed from the This module. End SubSub Activity_create (firsttime as Boolean) ' Do not forget to load the layout file created with the visual designer. For example: ' Activity.loadlayout ("Layout1") Dim files as List files = listfilesbydate (file.dirrootexternal) Log (File S.SIZE-1) ' Returns-1 indicates that the directory is empty for i = 0 to files. Size-1 Dim FS as Fileandtime fs = files. Get (i) Log (fs. Name & ":" & Datetime.date (fs. Time)) NextEnd SubSub Activity_resumeend SubSub Activity_pause (userclosed as Boolean) End SubSub Listfilesbydate (Folder As String) as List Dim files As List files = file.listfiles (folder) ' File.listfiles returns all directories and file lists in the specified folder Dim Sortedfil Es as List sortedfiles.initialize for i = 0 to files. Size-1 ' List.size Returns the number of entries in the list Dim FS as Fileandtime FS. Name = files. Get (i) ' List.get returns the list of item I fs. Time = file.lastmodified (Folder, FS. Name) ' file.lastmodified returns the last modified date of the specified file Sortedfiles.add (FS) Next Sortedfiles.sorttype ("Time", False) ' List.sort Type sorts list by type, ture= ascending, false= descending Return sortedfilesend Sub