安卓:如何获取文件的创建日期?

这是我的做法

// Used to examplify deletion of files more than 1 month old

// Note the L that tells the compiler to interpret the number as a Long

final int MAXFILEAGE = 2678400000L; // 1 month in milliseconds

// Get file handle to the directory. In this case the application files dir

File dir = new File(getFilesDir().toString());

// Obtain list of files in the directory.

// listFiles() returns a list of File objects to each file found.

File[] files = dir.listFiles();

// Loop through all files

for (File f : files ) {

// Get the last modified date. Milliseconds since 1970

Long lastmodified = f.lastModified();

// Do stuff here to deal with the file..

// For instance delete files older than 1 month

if(lastmodified+MAXFILEAGE

f.delete();

}

}


饥荒蘑菇几天生长一次
智能城市软件系统主要功能有哪些