Sort files by date in Basic4android

Source: Internet
Author: User

#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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.